fetchProtocolBondMemberships
Reads a staker's entry in the pox-5 protocol-bond-memberships map directly, including an entry whose bond has ended.
Usage
import { fetchProtocolBondMemberships } from '@stacks/bitcoin-staking';
const entry = await fetchProtocolBondMemberships({
address: 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7',
network: 'mainnet',
});
if (entry) {
entry.bondIndex;
entry.amountSats; // sats, as a bigint
}Notes
Reads the
protocol-bond-membershipsmap through the node's/v2/map_entryendpoint, with no expiry filter. This is the same readunstake-sbtcmakes (L1267-L1269).fetchBondMembership goes through
get-bond-membershipinstead, which returnsnoneonce the bond's 12 reward cycles have passed.The entry stays after the bond ends. A later
register-for-bondoverwrites it, and astakethat rolls the bond into STX-only staking deletes it (L1071).A non-2xx response, or a response without
data, throws anErrorwhose message starts withError fetching map entry for map "protocol-bond-memberships".
Signature
opts is a NetworkClientParam plus address.
Returns
Promise<BondMembership | undefined>
Resolves to a BondMembership, or undefined when the map has no entry for the address.
Parameters
opts.address (required)
Type:
string
Stacks address of the staker, the map key. A contract principal (<address>.<contract-name>) is also accepted.
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?