fetchTotalSbtcStaked
Calls the pox-5 get-total-sbtc-staked read-only and returns the sats of sBTC that pox-5 holds for protocol bonds across all stakers.
Usage
import { fetchTotalSbtcStaked } from '@stacks/bitcoin-staking';
const totalSats = await fetchTotalSbtcStaked({ network: 'mainnet' }); // sats, as a bigintNotes
Reads the
total-sbtc-stakeddata-var throughget-total-sbtc-staked.Counts sBTC only. Sats locked on Bitcoin L1 are not included: a registration on the L1 path moves no sBTC into pox-5 (L684-L687).
Changes when sBTC moves in or out of pox-5: the net transfer in
roll-sbtc(L1938-L1979), called byregister-for-bondandstake, and the withdrawal inunstake-sbtc(L1317-L1320).Throws an
Errorif the node returns a non-2xx status (the message starts withError calling read-only function.) or answersokay: false(the message is the node'scause).
Signature
function fetchTotalSbtcStaked(opts?: NetworkClientParam): Promise<bigint>;opts is a NetworkClientParam.
Returns
Promise<bigint>
Total sBTC held for protocol bonds, in sats.
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?