🛠️
Stacks Documentation
  • Start Here
  • 🧠Concepts
    • Stacks 101
      • What Is Stacks?
      • Bitcoin Connection
      • Proof of Transfer
      • Stacks Among Other Layers
      • Financial Incentive and Security Budget
    • Network Fundamentals
      • Network Basics
      • Mainnet and Testnets
      • Accounts
      • Authentication
      • Bitcoin Name System
      • SIPs
      • Technical Specifications
    • Block Production
      • Mining
      • Signing
      • Bitcoin Finality
      • Bitcoin Reorgs
      • Stacking
    • Transactions
      • How Transactions Work
      • Post Conditions
    • Clarity
      • Overview
      • Decidability
    • sBTC
      • Core Features
      • sBTC Operations
        • Deposit
        • Withdrawal
        • Deposit vs Withdrawal Times
      • Emily API
      • Peg Wallet UTXO
      • Clarity Contracts
        • sBTC Registry
        • sBTC Token
        • sBTC Deposit
        • sBTC Withdrawal
      • Auxiliary Features
        • Transaction Fee Sponsorship
        • Signer Wallet Rotation
      • Walkthroughs
        • Signer Process Walkthrough
        • sBTC Transaction Walkthrough
      • sBTC FAQ
    • Gaia
      • Configuration
      • Deploy Gaia Hub
      • Amazon EC2
      • Linux
      • Mac OS
  • 🛠️Guides & Tutorials
    • Developer Quickstart
    • Clarity Crash Course
    • Build a Borrowing & Lending Protocol
    • Bitcoin Integration
      • Sending Bitcoin with Leather Wallet
      • Verifying a Bitcoin Transaction
      • Parsing a Bitcoin Transaction
    • Create Tokens
      • Creating a NFT
      • Creating a Fungible Token
    • Build a Frontend
      • Post Conditions with Stacks.js
      • Authentication with Stacks.js
      • Sending Transactions with Stacks.js
    • Testing Smart Contracts
      • Fuzz Testing
    • Run a Node
      • Run a Node with Docker
      • Run a Node with Digital Ocean
      • Run a Node with a Hosted Provider
      • Run a Node with Quicknode
      • Run a Bitcoin Node
      • Run a Pruned Bitcoin Node
    • Run a Miner
      • Miner Prerequisites
      • Miner Costs and Fees
      • Mine Testnet Stacks Tokens
      • Mine Mainnet Stacks Tokens
      • Verify Miner
    • Run a Signer
      • Signer Quickstart
      • How to Read Signer Logs
      • How to Monitor a Signer
      • Best practices for running a Signer
      • OpSec Best Practices
    • sBTC
      • How to Run an sBTC Signer
      • Best practices for running an sBTC Signer
      • How to Use the sBTC Bridge
      • Earn sBTC Rewards
    • Stack STX
      • Solo Stack
      • Operate a Pool
      • Stack with a Pool
      • Increase Stacked Position
      • Stop Stacking
    • Oracles
    • Community Tutorials
  • 📚Reference
    • API
    • Clarity Types
    • Clarity Functions
    • Clarity Keywords
    • Stacks Node Configuration
    • Signer Configuration
    • Stacks Tooling
  • 🏗️Example Contracts
    • Audited Starter Contracts
    • Stacking
    • BNS
    • Multi Send
  • 🧡Press & Top Links
    • 🔶2024
      • 🔸January 2024
      • 🔸February 2024
      • 🔸March 2024
      • 🔸April 2024
      • 🔸May 2024
      • 🔸June 2024
      • 🔸July 2024
      • 🔸August 2024
      • 🔸September 2024
      • 🔸October 2024
      • 🔸November 2024
      • 🔸December 2024
    • 🔶2025
      • 🔸January 2025
      • 🔸February 2025
      • 🔸March 2025
  • 🧡Bitcoin Theses and Reports
    • 🟠Bitcoin Theses
    • 📙Bitcoin Reports
  • Contribute
Powered by GitBook
On this page
  • Introduction
  • Running a Bitcoin Mainnet Full Node
  • Running a Stacks Blockchain miner
  • Optional: Running a Stacks Blockchain miner with Docker
  • Optional: Running in Kubernetes with Helm

Was this helpful?

  1. Guides & Tutorials
  2. Run a Miner

Mine Mainnet Stacks Tokens

PreviousMine Testnet Stacks TokensNextVerify Miner

Last updated 5 months ago

Was this helpful?

Introduction

For more on the technical details of mining, please review the mining guide.

The following is an abridged version of the , written for a Linux system. If you're on Windows or MacOS, there will be some slight modifications needed (PR's welcome!).

If you're interested in mining on the Stacks mainnet, you can find instructions on how to do that here:

Running a Bitcoin Mainnet Full Node

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

First, download a , or (there may be some extra requirements to building, ).

If you want to learn more about the technical details of mining, please review the mining guide:

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

Update the Bitcoin Configuration File

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 stacks 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
disablewallet=0
datadir=/bitcoin
rpcuser=btcuser
rpcpassword=btcpass
rpcallowip=0.0.0.0/0
bind=0.0.0.0:8333
rpcbind=0.0.0.0:8332
dbcache=512
banscore=1
rpcthreads=256
rpcworkqueue=256
rpctimeout=100
txindex=1

Start Bitcoin

Finally, start bitcoind as follows (adjust the conf path to where it was created in the previous step, i.e. $HOME/bitcoin.conf):

bitcoind -conf=$HOME/bitcoin.conf

Note: It will take a few hours for the node to synchronize with Bitcoin Mainnet.

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/debug.log):

$ bitcoin-cli \
 -rpcconnect=127.0.0.1 \
 -rpcport=8332 \
 -rpcuser=btcuser \
 -rpcpassword=btcpass \
getblockchaininfo | jq .blocks
836745

Running a Stacks Blockchain miner

Tip: It is recommended to use a persistent location for the chainstate, in the steps below we're using /stacks-blockchain.

Generate a keychain

First, a keychain needs to be generated. With this keychain, we'll purchase some BTC from a cryptocurrency exchange, and then use that BTC to start mining.

npx @stacks/cli make_keychain 2>/dev/null | jq -r

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

{
  "mnemonic": "spare decade dog ghost luxury churn flat lizard inch nephew nut drop huge divert mother soccer father zebra resist later twin vocal slender detail",
  "keyInfo": {
    "privateKey": "ooxeemeitar4ahw0ca8anu4thae7aephahshae1pahtae5oocahthahho4ahn7eici",
    "address": "SPTXOG3AIHOHNAEH5AU6IEX9OOTOH8SEIWEI5IJ9",
    "btcAddress": "Ook6goo1Jee5ZuPualeiqu9RiN8wooshoo",
    "wif": "rohCie2ein2chaed9kaiyoo6zo1aeQu1yae4phooShov2oosh4ox",
    "index": 0
  }
}

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

The above wif (Kyk49jsPGen5C1ThhyJJH4CndLk8yLESuQJVGsbbTV3FFF9CRTJG) will then need to be imported into the bitcoin mainnet network.

Next, a bitcoin wallet is created:

bitcoin-cli \
  -rpcconnect=127.0.0.1 \
  -rpcport=8332 \
  -rpcuser=btcuser \
  -rpcpassword=btcpass \
  createwallet \
  wallet_name="miner" \
  disable_private_keys=false \
  blank=false \
  passphrase="" \
  avoid_reuse=false \
  descriptors=false \
  load_on_startup=true

Now, import your wif (bitcoin private key) inside the newly created wallet.

Note: Be sure to replace <wif from JSON above> with the wif value in the Generate a keychain step.

bitcoin-cli \
  -rpcport=8332 \
  -rpcuser=btcuser \
  -rpcpassword=btcpassword \
  importprivkey <wif from JSON above>

Note: The import may take a while, because a wallet rescan is triggered. After the import has completed successfully, you can check that the address is imported with getaddressinfo.

bitcoin-cli \
  -rpcconnect=127.0.0.1 \
  -rpcport=8332 \
  -rpcuser=btcuser \
  -rpcpassword=btcpass \
  getaddressinfo <btcAddress from JSON above>

Update the Stacks Blockchain Configuration File

Next, update the stacks configuration:

  • Optional, but recommended: Use a persistent directory to store the Stacks chainstate, i.e. working_dir = "/stacks-blockchain"

  • From the make_keychain step, modify the seed and mining_key values with privatekey

  • Store the following configuration somewhere on your filesystem (ex: $HOME/mainnet-miner-conf.toml)

[node]
working_dir = "/stacks-blockchain"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"
seed = "<privateKey from JSON above>"
miner = true
bootstrap_node = "02196f005965cebe6ddc3901b7b1cc1aa7a88f305bb8c5893456b8f9a605923893@seed.mainnet.hiro.so:20444,02539449ad94e6e6392d8c1deb2b4e61f80ae2a18964349bc14336d8b903c46a8c@cet.stacksnodes.org:20444,02ececc8ce79b8adf813f13a0255f8ae58d4357309ba0cedd523d9f1a306fcfb79@sgt.stacksnodes.org:20444,0303144ba518fe7a0fb56a8a7d488f950307a4330f146e1e1458fc63fb33defe96@est.stacksnodes.org:20444"
mine_microblocks = false

[burnchain]
wallet_name = "miner"
chain = "bitcoin"
mode = "mainnet"
peer_host = "127.0.0.1"
username = "<bitcoin config rpcuser>"
password = "<bitcoin config rpcpassword>"
rpc_port = 8332
peer_port = 8333
satoshis_per_byte = 100
burn_fee_cap = 450000

[miner]
mining_key = "<privateKey from JSON above>"
activated_vrf_key_path = "/stacks-blockchain/saved_vrf_key.json"

[connection_options]
private_neighbors = false

Start the Stacks Blockchain

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

stacks-node start --config $HOME/mainnet-miner-conf.toml

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

Enable Debug Logging

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:

STACKS_LOG_DEBUG=1 stacks-node start --config $HOME/mainnet-miner-conf.toml

Optional: Running a Stacks Blockchain miner with Docker

Alternatively, you can run a Stacks mainnet miner with Docker.

Generate a Keychain and Get Some Tokens

Generate a keychain:

docker run -i node:20-alpine npx @stacks/cli make_keychain 2>/dev/null | jq -r

Update Stacks Blockchain Docker Configuration File

Use the steps outlined above to create the configuration file.

Start the Stacks Blockchain miner with Docker

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

docker run -d \
  --name stacks_miner \
  --rm \
  --network host \
  -e RUST_BACKTRACE="full" \
  -e STACKS_LOG_DEBUG="1" \
  -v "$HOME/mainnet-miner-conf.toml:/src/stacks-node/mainnet-miner-conf.toml" \
  -v "/stacks-blockchain:/stacks-blockchain" \
  -p 20443:20443 \
  -p 20444:20444 \
  blockstack/stacks-blockchain:latest \
/bin/stacks-node start --config /src/stacks-node/mainnet-miner-conf.toml

You can review the node logs with this command:

docker logs -f stacks_miner

Optional: Running in Kubernetes with Helm

Ensure you have the following prerequisites installed:

Generate keychain and get some tokens

Use the steps outlined above

Install the chart and run the miner

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/stacks-blockchain \
  --set config.node.miner=true \
  --set config.node.seed="your-privateKey-from-generate-keychain-step" \
  --set config.burnchain.mode="mainnet"

You can review the node logs with this command:

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

First, download the latest tagged , or (there may be some extra requirements to building, ).

To create a keychain, the simplest way is to use the with the make_keychain command.

Once imported, we need to get some BTC to that address. You should be able to transfer BTC to this address using a cryptocurrency exchange such as , , or .

Now, we need to configure our node to use this Bitcoin keychain. Copy the to your local machine in a memorable location like $HOME/mainnet-miner-conf.toml.

Ensure you have installed.

We need to get some BTC to that address. You should be able to transfer BTC to this address using a cryptocurrency exchange such as , , or .

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

(Only needed if standing up a local Kubernetes cluster)

For more information on the Helm chart and configuration options, please refer to the .

🛠️
walkthrough here
Ensure your computer meets the minimum hardware requirements before continuing.
bitcoin binary
build from source
defined here
stacks blockchain binary
build from source
defined here
stacks-cli
Coinbase
Binance
Kraken
sample mainnet miner config
Docker
Coinbase
Binance
Kraken
stacks-blockchain Helm chart
Docker
minikube
kubectl
helm
chart's homepage