firstPox5RewardCycle
Returns the first reward cycle in which pox-5 is active, which is also the first cycle of bond 0. Pure computation: reads the pox-5 entry of poxInfo.contractVersions.
Usage
import { fetchPoxInfo, firstPox5RewardCycle } from '@stacks/bitcoin-staking';
const poxInfo = await fetchPoxInfo({ network: 'mainnet' });
const firstCycle = firstPox5RewardCycle(poxInfo);
if (firstCycle === undefined) {
// pox-5 has not activated on this network
}Notes
Returns
firstRewardCycleIdof thecontractVersionsentry whosecontractIdends in.pox-5, orundefinedwhen there is none.In the contract,
set-burnchain-parameterssets thefirst-pox-5-reward-cycleandfirst-bond-period-cycledata-vars to the same value. The SDK uses this result asfirst-bond-period-cyclein bondPeriodToRewardCycle and the helpers built on it, which throw when it isundefined.This value comes from the node's
/v2/poxresponse, not from the contract. To read the contract's value, call theget-first-pox-5-reward-cycleread-only.On mainnet both are 141:
/v2/poxreportsfirst_reward_cycle_id141 for pox-5, and the contract'sfirst-bond-period-cycledata-var readsu141. Bond 1, the first bond set up on mainnet, starts at reward cycle 143, Bitcoin block 966,350.
Signature
Returns
number | undefined
The first pox-5 reward cycle, or undefined if poxInfo.contractVersions has no pox-5 entry.
Parameters
poxInfo (required)
Type:
PoxInfo
A PoxInfo, usually from fetchPoxInfo.
Was this helpful?