@stacks/stacking
Library for PoX Stacking.
Installation
npm install @stacks/stacking
Initialization
import { StacksTestnet, StacksMainnet } from '@stacks/network';
import { StackingClient } from '@stacks/stacking';
const address = 'ST3XKKN4RPV69NN1PHFDNX3TYKXT7XPC4N8KC1ARH';
const network = new StacksTestnet();
const stacker = new Stacker(address, network);
Check stacking eligibility
const stackingEligibility = await client.canStack({ poxAddress, cycles });
Stack STX
const poxAddress = '1Xik14zRm29UsyS6DjhYg4iZeZqsDa8D3';
const amountMicroStx = new BN(100000000000);
const cycles = 10;
const key = 'd48f215481c16cbe6426f8e557df9b78895661971d71735126545abddcd5377001';
const burnBlockHeight = 2000;
const stackingResults = await client.stack({
amountMicroStx,
poxAddress,
cycles,
key,
burnBlockHeight,
});
Will Stacking be executed in the next cycle?
const stackingEnabledNextCycle = await client.isStackingEnabledNextCycle();
How long (in seconds) is a Stacking cycle?
const cycleDuration = await client.getCycleDuration();
How much time is left (in seconds) until the next cycle begins?
const secondsUntilNextCycle = await client.getSecondsUntilNextCycle();
Get PoX info
const poxInfo = await client.getPoxInfo();
Get Stacks node info
const coreInfo = await client.getCoreInfo();
Get account balance
const responseBalanceInfo = await client.getAccountBalance();
Does account have sufficient STX to meet minimum threshold?
const hasMinStxAmount = await client.hasMinimumStx();
Get account stacking status
const stackingStatus = await client.getStatus();
stackingStatus: