fetchEligibleSetBondAdmin
Dry-runs the only check of pox-5 set-bond-admin: that the caller is the current bond admin. Reads the admin with fetchBondAdmin and compares. Run it before buildSetBondAdmin.
Usage
import { fetchEligibleSetBondAdmin } from '@stacks/bitcoin-staking';
const result = await fetchEligibleSetBondAdmin({
caller: 'SP72DMR3MJKS7RVBY33JVV7EEJSQ1PYDVKDP10FX', // initial mainnet bond-admin in the pox-5 source
network: 'mainnet',
});
if (!result.ok) console.log(result.reasons); // [1]: Pox5ErrorCode.UnauthorizedNotes
Mirrors
set-bond-admin, which assertscontract-callerequals thebond-admindata-var and otherwise fails withERR_UNAUTHORIZED (u1).The comparison is an exact string match against the current
bond-adminprincipal.Throws if the
/v2/data_varread returns a non-2xx response.
Signature
opts also takes the NetworkClientParam fields.
Returns
Promise<EligibilityResult>
Resolves to an EligibilityResult: { ok: true } if caller is the current bond admin, otherwise { ok: false, reasons: [Pox5ErrorCode.Unauthorized] }.
Parameters
opts.caller (required)
Type:
string
The principal that would send the transaction (the contract's contract-caller).
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?