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

fetchBondAdmin

Reads the pox-5 bond-admin data-var and returns the principal that can set up protocol bonds and transfer the role.


Usage

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

const bondAdmin = await fetchBondAdmin({ network: 'mainnet' });

Notes

  • Reads the bond-admin data-var through the node's /v2/data_var endpoint. pox-5 has no read-only accessor for it.

  • setup-bond (L532) and set-bond-admin (L460) fail with ERR_UNAUTHORIZED (u1) unless contract-caller equals this principal.

  • The value changes when set-bond-admin succeeds, so read it rather than caching it. On networks other than mainnet, the node sets the initial value from its configuration before deploying pox-5.

  • A non-2xx response throws an Error whose message starts with Error fetching bond-admin. and includes the status code and URL.

Reference Link


Signature

function fetchBondAdmin(opts?: NetworkClientParam): Promise<string>;

opts is a NetworkClientParam.


Returns

Promise<string>

The bond-admin principal as a Stacks address string. A contract principal comes back as <address>.<contract-name>.


Parameters

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?