- Let's generate an address!
$ blockstack-cli generate-sk --testnet > testnet_key.json
- Set some envars
$ secret_key=$(cat ./testnet_key.json | jq -r .secretKey)
$ stx_addr=$(cat ./testnet_key.json | jq -r .stacksAddress)
- 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
- 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 thec32check
npm package to do this:
$ node -e "const c32 = require('c32check'); console.log('0x' + c32.c32addressDecode('$stx_addr')[1])"
0x5e230097e7d9568810b336b8c8ed6bed21ac2f96
- 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
- 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
@kantai - the faucet call requires the
stacking=true
URL param now