buildSignerCalldata
Encodes a Bitcoin payout address and a maximum fee into the signerCalldata bytes that buildStake, buildStakeUpdate, buildRegisterForBond and buildUpdateBondRegistration pass to the signer-manager. Pure computation.
Usage
import { buildSignerCalldata } from '@stacks/bitcoin-staking';
const signerCalldata = buildSignerCalldata({
poxAddress: 'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4',
maxFeeSats: 1_000n,
network: 'mainnet',
});Notes
The bytes are the Clarity serialization of
{ pox-addr: { version, hashbytes }, max-fee }.pox-5 does not read them. It forwards them to the signer-manager's
validate-stake!as an(optional (buff 500))(pox-5.clar L392-L427), so what they do depends on the signer-manager. The SDK documents this format as an election of an L1 BTC payout topoxAddress; omittingsignerCalldatakeeps the sBTC payout.pox-5 does not validate the address, so a wrong but well-formed address is accepted on-chain. Decode the bytes with parseSignerCalldata to check them before you build.
A string
poxAddressmust be a P2PKH, P2SH, P2WPKH, P2WSH or P2TR address, or the function throws. Withnetwork, an address from another network throws, for example abc1address withnetwork: 'testnet'. Withoutnetwork, any network's address is accepted.A BtcAddressRepr
poxAddressmust have a known version and the matchingdatalength, or the function throws.
Signature
opts is a SignerCalldataL1Payout.
Returns
Uint8Array
The serialized Clarity tuple.
Parameters
opts.poxAddress (required)
Type:
string | BtcAddressRepr
Bitcoin address to pay rewards to, as an address string or a parsed BtcAddressRepr.
opts.maxFeeSats (required)
Type:
IntegerType
Largest sBTC fee, in sats, the staker accepts on the L1 BTC withdrawal.
opts.network (optional)
Type:
StacksNetworkName | StacksNetwork
When poxAddress is a string, the network it must belong to. Omit it to accept any network's address.
Was this helpful?