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 Nodearrow-up-right

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.

First, download a bitcoin binaryarrow-up-right

circle-info

TIP

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

Update the Bitcoin Configuration Filearrow-up-right

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)

Start Bitcoinarrow-up-right

Finally, start bitcoind as follows:

circle-info

NOTE

The node will need a few hours to synchronize with the Bitcoin testnet.

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):


Running a Base Blockchain minerarrow-up-right

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

circle-info

TIP

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

Generate a keychainarrow-up-right

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.

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

circle-info

DANGER

Do not lose this information - we'll need to use the privateKey and btcAddress fields in later steps.

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

circle-info

NOTE

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

Once imported, we need to get some testnet BTC to that address. Grab the btcAddress field, and paste it into this Bitcoin testnet faucetarrow-up-right. You'll be sent 0.01 testnet BTC to that address.

Update the Base Blockchain Configuration Filearrow-up-right

Now, we need to configure our node to use this Bitcoin keychain.

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)

Start the Base Blockchainarrow-up-right

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

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

Enable Debug Loggingarrow-up-right

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:


Optional: Running a Base Blockchain miner with Dockerarrow-up-right

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

circle-info

CAUTION

Ensure you have Dockerarrow-up-right installed

Generate a Keychain and Get Some Tokensarrow-up-right

Generate a keychain:

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 Filearrow-up-right

Use the steps oulined above to create the configuration filearrow-up-right

Start the Base Blockchain miner with Dockerarrow-up-right

circle-info

INFO

The ENV VARS RUST_BACKTRACE and BASE_LOG_DEBUG are optional. If removed, debug logs will be disabled

You can review the node logs with this command:


Optional: Running in Kubernetes with Helmarrow-up-right

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

Ensure you have the following prerequisites installed:

Generate keychain and get some tokensarrow-up-right

Use the steps outlined abovearrow-up-right

Install the chart and run the minerarrow-up-right

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

You can review the node logs with this command:

Last updated