Skip to content

Instantly share code, notes, and snippets.

@kantai

kantai/stacking-runbook.md Secret

Last active Oct 19, 2020
Embed
What would you like to do?
  1. Let's generate an address!
$ blockstack-cli generate-sk --testnet > testnet_key.json
  1. Set some envars
$ secret_key=$(cat ./testnet_key.json | jq -r .secretKey)
$ stx_addr=$(cat ./testnet_key.json | jq -r .stacksAddress)
  1. Now we need some STX, let's ask the faucet
$ curl -X POST https://stacks-node-api.krypton.blockstack.org/extended/v1/faucets/stx\?address\=$stx_addr
  1. Once we have the STX, we should create a stack-stx transaction to participate. First, we need to raw hex bytes of the address we'll use to receive STX. I use the c32check npm package to do this:
$ node -e "const c32 = require('c32check'); console.log('0x' + c32.c32addressDecode('$stx_addr')[1])"
0x5e230097e7d9568810b336b8c8ed6bed21ac2f96
  1. Now we build and sign our transaction
$ blockstack-cli contract-call --testnet $secret_key \
                 243 0 \
                 ST000000000000000000002AMW42H pox stack-stx \
                 -e "(* u33 (pow u10 u14))" \
                 -e '{ hashbytes: 0x5e230097e7d9568810b336b8c8ed6bed21ac2f96, version: 0x00 }' \
                 -e "u3" \
                 -e "u400" > /tmp/transaction.hex

The first few arguments specify your STX testnet key, the fee to pay for the transaction, and the nonce of the transaction. Then, we specify the PoX smart contract and function to call. Then there are four arguments to the Clarity function:

  1. The total number of microSTX to stack: here we use 3.3e15
  2. The PoX rewards address to receive awards. This is the hex bytes we generated before.
  3. The number of reward cycles to lock up for.
  4. The burn block height at which this Stacking transaction should be considered valid. This burn block height
      should be close to the current chain tip -- you can find the current `burn_block_height` by querying http://krypton.blockstack.org:20443/v2/info
  1. Broadcast the transaction
cat /tmp/transaction.hex | xxd -r -p | curl -v -X POST --header "Content-Type:application/octet-stream" --data-binary @- http://krypton.blockstack.org:20443/v2/transactions
@diwakergupta

This comment has been minimized.

Copy link

@diwakergupta diwakergupta commented Sep 24, 2020

This is great, thanks Aaron!

@agraebe

This comment has been minimized.

Copy link

@agraebe agraebe commented Sep 24, 2020

fantastic!

@agraebe

This comment has been minimized.

Copy link

@agraebe agraebe commented Sep 24, 2020

@kantai - Does this use the stacks-2.0-tx (PR) version of the CLI?

@kantai

This comment has been minimized.

Copy link
Owner Author

@kantai kantai commented Sep 24, 2020

This uses the binary blockstack-cli produced by the stacks-blockchain repo's cargo build.

@agraebe

This comment has been minimized.

Copy link

@agraebe agraebe commented Sep 24, 2020

I just tried this and failed at the faucet step (assuming reasoned by the fixes we're currently working on). I also noticed that the faucet URL needs to be updated: https://stacks-node-api.blockstack.org/extended/v1/faucets/stx\?address\=$stx_addr

@jcnelson

This comment has been minimized.

Copy link

@jcnelson jcnelson commented Sep 25, 2020

This is great @kantai! Just a small nit: 1. The total number of STX to stack: here we use 3.3e15 <-- the units here are uSTX.

Question: would it be possible to extend the runbook to show how a user will know whether or not they've received their BTC reward from Stacking?

@agraebe

This comment has been minimized.

Copy link

@agraebe agraebe commented Oct 5, 2020

@kantai - the faucet call requires the stacking=true URL param now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.