// a BTC address for reward payouts constpoxAddress = 'mvuYDknzDtPgGqm2GnbAbmGMLwiyW3AwFP'; // number cycles to stack constcycles = 3; // how much to stack, in microSTX constamountMicroStx = 100000000000n; // private key for transaction signing constprivateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; // block height at which to stack constburnBlockHeight = 2000;
// Refer to initialization section to create client instance conststackingResults = awaitclient.stack({ amountMicroStx, poxAddress, cycles, privateKey, burnBlockHeight, });
// STX address of the delegator constdelegateTo = 'ST2MCYPWTFMD2MGR5YY695EJG0G1R4J2BTJPRGM7H'; // burn height at which the delegation relationship should be revoked (optional) constuntilBurnBlockHeight = 5000; // how much to stack, in microSTX constamountMicroStx = 100000000000n; // private key for transaction signing constprivateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001';
// for mainnet: const network = new StacksMainnet(); constnetwork = newStacksTestnet(); // the stacks STX address constaddress = 'ST3XKKN4RPV69NN1PHFDNX3TYKXT7XPC4N8KC1ARH'; // delegators would initiate a different client constdelegatorAddress = 'ST22X605P0QX2BJC3NXEENXDPFCNJPHE02DTX5V74'; // delegator private key for transaction signing constdelegatorPrivateKey = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001'; // the BTC address for reward payouts constdelegatorBtcAddress = 'msiYwJCvXEzjgq6hDwD9ueBka6MTfN962Z'; // how much to stack, in microSTX constamountMicroStx = 100000000000n; // block height at which to stack constburnBlockHeight = 2000; // number cycles to stack constcycles = 3; // if you call this method multiple times in the same block, you need to increase the nonce manually letnonce = awaitgetNonce(delegatorAddress, network); nonce = nonce + 1n;
@stacks/stacking
Library for PoX Stacking.
Installation
Initialization
Initialize a
StackingClient
to interact with the Stacking contract.Note: the
StackingClient
sets its transactionsAnchorMode
toAny
.Check stacking eligibility
Stack STX
Will Stacking be executed in the next cycle?
How long (in seconds) is a Stacking cycle?
How much time is left (in seconds) until the next cycle begins?
Get PoX info
Get Stacks node info
Get account balance
Does account have sufficient STX to meet minimum threshold?
Get account stacking status
Delegation
There are four methods available for delegation, two for the delegators and two for the delegatee.
Delegatee
If you are the account owner ("stacker"), you can delegate or revoke delegation rights.
Delegate STX
Revoke delegation
Delegator
If you are the delegator, you can stack ("lock up") tokens for your users and commit to stacking participation for upcoming reward cycles.
Stack delegated STX
Commit to stacking
Get burnchain rewards
Get burnchain rewards total
Get burnchain reward holders