DEV Community

Cover image for Running a Stacks Node and Mining STX Tokens for the First Time: A Guide for All the Non-Tech-Savvy People
Jun Gong
Jun Gong

Posted on

Running a Stacks Node and Mining STX Tokens for the First Time: A Guide for All the Non-Tech-Savvy People

For people like me — an absolute noob, with a little help from Docker

Before we get into all the “technical” stuff, a little bit about myself: I’m a tech startup person with a finance / marketing background, I’ve been bullish on DeFi since early 2019, and I’m a proud yield farmer. So, you can tell that I’m NOT tech-savvy and I know ZERO coding stuff.

But why on the earth do I still want to go through all the troubles to set up and run a miner on Stacks 2.0 testnet? Because of my curiosity — what happens if we bring DeFi to the Bitcoin ecosystem? And I believe Stacks 2.0 will be the next DeFi powerhouse, and most importantly, the whole process of setting up a node on Stacks testnet and running a miner, turned out not to be very complicated as I thought.

If you’re naturally curious and not very tech-savvy, but you want to join the DeFi on Bitcoin movement before everyone else does, and earn STX rewards, please keep reading 🙂

Hopefully, after reading this guide, you’ll be able to:

– Run your testnode on the Stacks 2.0 blockchain
– Set up and run a miner on the Stacks 2.0


My Computer Setup

MacBook Air with macOS Catalina, really basic one, nothing fancy.

Running a Testnode

Step 1: Download and Install Docker

Go to Docker and install Docker on your Mac. It’s free, if you have a privacy setting as I do, make sure to manually change Docker as a trusted software so it can run on your Mac.

Step 2: Open Terminal

Open the /Applications/Utilities folder on your Mac, type in a search to find the Terminal then double-click it.

Type the command as below — copy those commands and paste in Terminal and press Enter:

docker run -d \
--name stacks_follower \
--rm \
-e RUST_BACKTRACE="full" \
-e BLOCKSTACK_DEBUG="1" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:latest \
/bin/stacks-node krypton

The installations will process automatically, and once complete you will see a blank command shows up. And then, type command:

docker logs -f stacks_follower

You can see this in Docker:
Alt Text

Looks like the node connects to the Stacks 2.0 testnet now.

Mining Stacks Token on the Testnet

Step 1: Generate keychain

Type:

docker run -i node:14-alpine npx @stacks/cli make_keychain -t 2>/dev/null

and press Enter

Then type:

'replace with btcAddress property from your keychain

curl -XPOST "https://stacks-node-api.blockstack.org/extended/v1/faucets/btc?address=" | json_pp'

and press Enter.

Step 2: Create a config file directory

Type:

mkdir -p $HOME/stacks

and press Enter

After it’s complete and you see the blank command, type:

[node]
working_dir = "/root/stacks-node/current"
rpc_bind = "0.0.0.0:20443"
p2p_bind = "0.0.0.0:20444"'
Enter your private key here!
seed = "replace-with-your-privateKey-from-generate-keychain-step"
miner = true
[burnchain]
chain = "bitcoin"
mode = "krypton"
peer_host = "bitcoind.krypton.blockstack.org"
process_exit_at_block_height = 5340
burnchain_op_tx_fee = 5500
commit_anchor_block_within = 10000
rpc_port = 18443
peer_port = 18444
[[mstx_balance]]
address = "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6"
amount = 10000000000000000

[[mstx_balance]]

address = "ST11NJTTKGVT6D1HY4NJRVQWMQM7TVAR091EJ8P2Y"

amount = 10000000000000000

[[mstx_balance]]

address = "ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR"

amount = 10000000000000000

[[mstx_balance]]

address = "STRYYQQ9M8KAF4NS7WNZQYY59X93XEKR31JP64CP"

amount = 10000000000000000`
Enter fullscreen mode Exit fullscreen mode

And press Enter

Step 3: Run the miner

Type:

docker run -d \
--name stacks_miner \
--rm \
-e RUST_BACKTRACE="full" \
-e BLOCKSTACK_DEBUG="1" \
-v "$HOME/stacks/Config.toml:/src/stacks-node/Config.toml" \
-p 20443:20443 \
-p 20444:20444 \
blockstack/stacks-blockchain:latest \
/bin/stacks-node start --config /src/stacks-node/Config.toml
`

And press Enter.

You will see this “crazy stuff” popping up but don’t panic, it means things are up and running!

Anyway, that’s all I did. I followed the original guide here. Blockstack does recommend a few different ways via Rust and Virtual Machine (Oracle VirtualBox) to help you run a miner on Stacks 2.0 other than Docker.

Also, you can download the pre-made binaries (node) here. Unfortunately, only Docker works on my end. I will ask the community to help me look into it and hopefully, I can set up STX mining before Stacks 2.0 mainnet goes live. If you made it to the end on Rust or VM, please share your tutorial with me!

Top comments (3)

Collapse
 
scottemak profile image
Scott McKenna

Hey, I keep getting this error:

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested

what does this mean and what can I do to fix it?

Collapse
 
mzcoderhub profile image
Galang YP

How bout using it on windows ?

Collapse
 
7000gb profile image
7000gb

Does this require running the full Bitcoin Core blockchain as a pre requsite?