> For the complete documentation index, see [llms.txt](https://base-tech.gitbook.io/base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://base-tech.gitbook.io/base/nodes-and-miners/mine-testnet-base-tokens.md).

# Mine testnet Base tokens

## Introduction

To learn more about mining's technical details, please refer to the mining guide.The following is a condensed version of the walkthrough for a Linux system. If you are using Windows or MacOS, some slight modifications may be necessary (PR's welcome!).

## Running a Bitcoin Testnet Full Node[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#running-a-bitcoin-testnet-full-node) <a href="#running-a-bitcoin-testnet-full-node" id="running-a-bitcoin-testnet-full-node"></a>

To participate as a miner on testnet, you must have access to a testnet bitcoin node with a wallet (and the wallet's private key). One way to accomplish this is to run bitcoin locally.

* [Ensure your computer meets the minimum hardware requirements before continuing.](https://bitcoin.org/en/bitcoin-core/features/requirements#system-requirements)

First, download a [bitcoin binary](https://bitcoin.org/en/download)

{% hint style="info" %}
TIP

It is recommened to use a persistent location for the chainstate, in the steps below we're using `/bitcoin`
{% endhint %}

## Update the Bitcoin Configuration File[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#update-the-bitcoin-configuration-file) <a href="#update-the-bitcoin-configuration-file" id="update-the-bitcoin-configuration-file"></a>

Next, update the bitcoin configuration:

* **optional but recommended:** Use a persistent directory to store the Bitcoin chainstate, i.e. `datadir=/bitcoin`
* **optional but recommended:** Update the `rpcallowip` value to only allow `127.0.0.1`, or the base miner IPv4
* Modify the `rpcuser` and `rpcpassword` values from the defaults below
* Store the following configuration somewhere on your filesystem (ex: `$HOME/bitcoin.conf`)

```
server=1
testnet=1
disablewallet=0
datadir=/bitcoin
rpcuser=btcuser
rpcpassword=btcpass
rpcallowip=0.0.0.0/0
dbcache=512
banscore=1
rpcthreads=256
rpcworkqueue=256
rpctimeout=100
txindex=1

[test]
bind=0.0.0.0:18333
rpcbind=0.0.0.0:18332
rpcport=18332
```

## Start Bitcoin[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#start-bitcoin) <a href="#start-bitcoin" id="start-bitcoin"></a>

Finally, start bitcoind as follows:

```
bitcoind -conf=$HOME/bitcoin.conf
```

{% hint style="info" %}
NOTE

The node will need a few hours to synchronize with the Bitcoin testnet.
{% endhint %}

While it's syncing, you can track the progress with `bitcoin-cli` or the logfile (will be located where the chainstate is stored, i.e. `/bitcoin/testnet3/debug.log`):

```
$ bitcoin-cli \
 -rpcconnect=localhost \
 -rpcport=18332 \
 -rpcuser=btcuser \
 -rpcpassword=btcpass \
getblockchaininfo | jq .blocks
2417570
```

***

## Running a Base Blockchain miner[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#running-a-stacks-blockchain-miner) <a href="#running-a-stacks-blockchain-miner" id="running-a-stacks-blockchain-miner"></a>

First, download a Base blockchain binary, or build from source

{% hint style="info" %}
TIP

It is recommened to use a persistent location for the chainstate, in the steps below we're using `/base-blockchain`
{% endhint %}

## Generate a keychain[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#generate-a-keychain) <a href="#generate-a-keychain" id="generate-a-keychain"></a>

First, a keychain needs to be generated. With this keychain, we'll get some testnet BTC from a faucet, and then use that BTC to start mining.

To create a keychain, the simplest way is to use the base-cli with the `make_keychain` command.

```
npx @base/cli make_keychain -t 2>/dev/null | jq -r
```

After this runs, you should see some JSON printed to the screen that looks like this:

```
{
  "mnemonic": "exhaust spin topic distance hole december impulse gate century absent breeze ostrich armed clerk oak peace want scrap auction sniff cradle siren blur blur",
  "keyInfo": {
    "privateKey": "2033269b55026ff2eddaf06d2e56938f7fd8e9d697af8fe0f857bb5962894d5801",
    "address": "STTX57EGWW058FZ6WG3WS2YRBQ8HDFGBKEFBNXTF",
    "btcAddress": "mkRYR7KkPB1wjxNjVz3HByqAvVz8c4B6ND",
    "index": 0
  }
}
```

{% hint style="info" %}
DANGER

**Do not lose this information** - we'll need to use the `privateKey` and `btcAddress` fields in later steps.
{% endhint %}

The above `btcAddress` (mkRYR7KkPB1wjxNjVz3HByqAvVz8c4B6ND) will then need to be imported into the bitcoin testnet network.

{% hint style="info" %}
NOTE

Be sure to replace `<btcAddress from JSON above>` with the bitcoin address in the "Generate a keychain" step
{% endhint %}

```
bitcoin-cli \
  -rpcport=18332 \
  -rpcuser=btcuser \
  -rpcpassword=btcpassword \
importaddress <btcAddress from JSON above>
```

Once imported, we need to get some testnet BTC to that address. Grab the `btcAddress` field, and paste it into [this Bitcoin testnet faucet](https://tbtc.bitaps.com/). You'll be sent `0.01` testnet BTC to that address.

## Update the Base Blockchain Configuration File[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#update-the-stacks-blockchain-configuration-file) <a href="#update-the-stacks-blockchain-configuration-file" id="update-the-stacks-blockchain-configuration-file"></a>

Now, we need to configure our node to use this Bitcoin keychain.&#x20;

Now, grab your `privateKey` from earlier when you ran the `make_keychain` command. Replace the `seed` and `local_peer_seed` field with your private key. Save and close this configuration file.

Next, update the bitcoin configuration:

* **optional but recommended:** Use a persistent directory to store the Base chainstate, i.e. `working_dir = "/base-blockchain"`
* From the `make_keychain` step, modify the `seed` and `local_peer_seed` values with `privatekey`
* Store the following configuration somewhere on your filesystem (ex: `$HOME/testnet-miner-conf.toml`)

```
[node]
working_dir = "/base-blockchain"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
seed = "<keychain privateKey>"
local_peer_seed = "<keychain privateKey>"
miner = true
bootstrap_node = "047435c194e9b01b3d7f7a2802d6684a3af68d05bbf4ec8f17021980d777691f1d51651f7f1d566532c804da506c117bbf79ad62eea81213ba58f8808b4d9504ad@testnet.base.tech:20444"
wait_time_for_microblocks = 10000

[burnchain]
chain = "bitcoin"
mode = "xenon"
peer_host = "127.0.0.1"
username = "<bitcoin config rpcuser>"
password = "<bitcoin config rpcpassword>"
rpc_port = 18332
peer_port = 18333

[[ustx_balance]]
address = "ST2QKZ4FKHAH1NQKYKYAYZPY440FEPK7GZ1R5HBP2"
amount = 10000000000000000

[[ustx_balance]]
address = "ST319CF5WV77KYR1H3GT0GZ7B8Q4AQPY42ETP1VPF"
amount = 10000000000000000

[[ustx_balance]]
address = "ST221Z6TDTC5E0BYR2V624Q2ST6R0Q71T78WTAX6H"
amount = 10000000000000000

[[ustx_balance]]
address = "ST2TFVBMRPS5SSNP98DQKQ5JNB2B6NZM91C4K3P7B"
amount = 10000000000000000
```

## Start the Base Blockchain[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#start-the-stacks-blockchain) <a href="#start-the-stacks-blockchain" id="start-the-stacks-blockchain"></a>

To run your miner, run this in the command line:

```
base-node start --config=$HOME/testnet-miner-conf.toml
```

Your node should start. It will take some time to sync, and then your miner will be running.

## Enable Debug Logging[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#enable-debug-logging) <a href="#enable-debug-logging" id="enable-debug-logging"></a>

In case you are running into issues or would like to see verbose logging, you can run your node with debug logging enabled. In the command line, run:

```
BASE_LOG_DEBUG=1 base node start --config=$HOME/testnet-miner-conf.toml
```

***

## Optional: Running a Base Blockchain miner with Docker[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#optional-running-a-stacks-blockchain-miner-with-docker) <a href="#optional-running-a-stacks-blockchain-miner-with-docker" id="optional-running-a-stacks-blockchain-miner-with-docker"></a>

Alternatively, you can run a Base testnet miner with Docker.

{% hint style="info" %}
CAUTION

Ensure you have [Docker](https://docs.docker.com/get-docker/) installed
{% endhint %}

## Generate a Keychain and Get Some Tokens[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#generate-a-keychain-and-get-some-tokens) <a href="#generate-a-keychain-and-get-some-tokens" id="generate-a-keychain-and-get-some-tokens"></a>

Generate a keychain:

```
docker run -i node:14-alpine npx @base/cli make_keychain 2>/dev/null | jq -r
```

Now, we need to get some tBTC. Grab the `btcAddress` field, and paste it into this Bitcoin testnet faucet. You'll be sent `0.01` tBTC to that address.

## Update Base Blockchain Docker Configuration File[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#update-stacks-blockchain-docker-configuration-file) <a href="#update-stacks-blockchain-docker-configuration-file" id="update-stacks-blockchain-docker-configuration-file"></a>

Use the steps oulined above to create the [configuration file](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#update-the-stacks-blockchain-configuration-file)

## Start the Base Blockchain miner with Docker[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#start-the-stacks-blockchain-miner-with-docker) <a href="#start-the-stacks-blockchain-miner-with-docker" id="start-the-stacks-blockchain-miner-with-docker"></a>

{% hint style="info" %}
INFO

The ENV VARS `RUST_BACKTRACE` and `BASE_LOG_DEBUG` are optional. If removed, debug logs will be disabled
{% endhint %}

```
docker run -d \
  --name base_miner \
  --rm \
  --network host \
  -e RUST_BACKTRACE="full" \
  -e BASE_LOG_DEBUG="1" \
  -v "$HOME/testnet-miner-conf.toml:/src/base-node/testnet-miner-conf.toml" \
  -v "/base-blockchain:/base-blockchain" \
  -p 20443:20443 \
  -p 20444:20444 \
  blockstack/base-blockchain:latest \
/bin/base-node start --config /src/base-node/testnet-miner-conf.toml
```

You can review the node logs with this command:

```
docker logs -f base_miner
```

***

## Optional: Running in Kubernetes with Helm[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#optional-running-in-kubernetes-with-helm) <a href="#optional-running-in-kubernetes-with-helm" id="optional-running-in-kubernetes-with-helm"></a>

In addition, you're also able to run a Base miner in a Kubernetes cluster.

Ensure you have the following prerequisites installed:

* [Docker](https://docs.docker.com/get-docker/)
* [minikube](https://minikube.sigs.k8s.io/docs/start/) (Only needed if standing up a local Kubernetes cluster)
* [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)
* [helm](https://helm.sh/docs/intro/install/)

## Generate keychain and get some tokens[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#generate-keychain-and-get-some-tokens) <a href="#generate-keychain-and-get-some-tokens" id="generate-keychain-and-get-some-tokens"></a>

Use the steps [outlined above](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#generate-a-keychain-and-get-some-tokens)

## Install the chart and run the miner[​](https://docs.stacks.co/docs/nodes-and-miners/miner-testnet#install-the-chart-and-run-the-miner) <a href="#install-the-chart-and-run-the-miner" id="install-the-chart-and-run-the-miner"></a>

To install the chart with the release name `my-release` and run the node as a miner:

```
minikube start # Only run this if standing up a local Kubernetes cluster
helm repo add blockstack https://charts.blockstack.xyz
helm install my-release blockstack/base-blockchain \
  --set config.node.miner=true \
  --set config.node.seed="replace-with-your-privateKey-from-generate-keychain-step" \
```

You can review the node logs with this command:

```
kubectl logs -l app.kubernetes.io/name=base-blockchain
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://base-tech.gitbook.io/base/nodes-and-miners/mine-testnet-base-tokens.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
