Running a Stacks Node and Mining STX Tokens for the First Time: A Guide for All the Non-Tech-Savvy People
Tags: bitcoin, blockstack, blockchain, node
Published: 2020-11-11 14:19:02

_For people like me — <b>an absolute noob</b>, 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](https://gongjunshanghai.com/2020/10/12/bringing-defi-to-bitcoin-ecosystem/), 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](https://blog.blockstack.org/krypton-launch-proof-of-transfer-now-implemented-on-the-stacks-2-0-testnet/), 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

_______________________________________________________

<h2>My Computer Setup</h2> 
MacBook Air with macOS Catalina, really basic one, nothing fancy. 

<h2>Running a Testnode</h2> 
<h3>Step 1: Download and Install Docker</h3> 
Go to [Docker](https://docs.docker.com/docker-for-mac/install/) 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.

<h3>Step 2: Open Terminal</h3>
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](https://dev-to-uploads.s3.amazonaws.com/i/jl84eudn64x5pwf3i4j6.png)

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

<h2>Mining Stacks Token on the Testnet</h2> 
<h3>Step 1: Generate keychain</h3>
Type: 

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

and press Enter

Then type: 

'replace <btc_address> with `btcAddress` property from your keychain

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

and press Enter.

<h3>Step 2: Create a config file directory</h3>
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`
```

And press Enter 

<h3>Step 3: Run the miner</h3>
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](https://docs.blockstack.org/mining#create-a-config-file-directory). 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](https://github.com/blockstack/stacks-blockchain/actions/runs/355947077). 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!