For the complete documentation index, see llms.txt. This page is also available as Markdown.

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 firstRewardCycleId of the contractVersions entry whose contractId ends in .pox-5, or undefined when there is none.

  • In the contract, set-burnchain-parameters sets the first-pox-5-reward-cycle and first-bond-period-cycle data-vars to the same value. The SDK uses this result as first-bond-period-cycle in bondPeriodToRewardCycle and the helpers built on it, which throw when it is undefined.

  • This value comes from the node's /v2/pox response, not from the contract. To read the contract's value, call the get-first-pox-5-reward-cycle read-only.

  • On mainnet both are 141: /v2/pox reports first_reward_cycle_id 141 for pox-5, and the contract's first-bond-period-cycle data-var reads u141. 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?