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

bondPeriodToBurnHeight

Returns a bond's start height: the first Bitcoin block of its first reward cycle. Pure computation that mirrors the pox-5 read-only bond-period-to-burn-height.


Usage

import { bondPeriodToBurnHeight, fetchPoxInfo } from '@stacks/bitcoin-staking';

const poxInfo = await fetchPoxInfo({ network: 'mainnet' });

const startHeight = bondPeriodToBurnHeight({ bondIndex: 3, poxInfo });
const blocksUntilStart = startHeight - poxInfo.currentBurnchainBlockHeight;

Notes

  • Computes rewardCycleToBurnHeight of bondPeriodToRewardCycle, both from poxInfo.

  • register-for-bond fails with ERR_BOND_ALREADY_STARTED (u43) from this height on, and setup-bond with ERR_CANNOT_SETUP_BOND_TOO_LATE (u3).

  • The bond is active above this height and up to bondPeriodToBurnHeight of bondIndex + 6 inclusive. See isBondActiveAtHeight.

  • Throws an Error whose message starts with pox-5 not activated yet if poxInfo.contractVersions has no pox-5 entry.

Reference Link


Signature


Returns

number

The Bitcoin block height at which the bond starts.


Parameters

opts.bondIndex (required)

  • Type: number

The bond index.

opts.poxInfo (required)

  • Type: PoxInfo

A PoxInfo, usually from fetchPoxInfo.

Was this helpful?