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

fetchProtocolBond

Calls the pox-5 get-protocol-bond read-only and returns a protocol bond's configuration, or undefined if setup-bond has not been called for that index.


Usage

import { fetchProtocolBond } from '@stacks/bitcoin-staking';

const bond = await fetchProtocolBond({ bondIndex: 1, network: 'mainnet' });
const isBondSetup = bond !== undefined;

Notes

  • get-protocol-bond returns (map-get? protocol-bonds bond-index), so the result matches fetchBond, which reads the map directly.

  • fetchBondStatus calls this function to decide isBondSetup when you do not pass it.

  • Throws an Error if the node returns a non-2xx status (the message starts with Error calling read-only function.) or answers okay: false (the message is the node's cause).


Signature

function fetchProtocolBond(
  opts: { bondIndex: number } & NetworkClientParam
): Promise<Bond | undefined>;

opts is a NetworkClientParam plus bondIndex.


Returns

Promise<Bond | undefined>

Resolves to a Bond, or undefined when the contract returns none.


Parameters

opts.bondIndex (required)

  • Type: number

Index of the protocol bond.

opts.network (optional)

  • Type: StacksNetworkName | StacksNetwork

The network to query: a name such as 'mainnet' or 'testnet', or a StacksNetwork object. Defaults to 'mainnet'.

opts.client (optional)

  • Type: { baseUrl?: string; fetch?: FetchFn }

Overrides the API base URL or the fetch function, for example to query your own node. Fields you set replace the network's defaults.

Was this helpful?