fetchRewards
Reads the sBTC, in sats, that pox-5 holds as rewards: its sBTC balance minus staked sBTC and the reserve balance. Wraps the pox-5 read-only get-rewards.
Usage
import { fetchRewards } from '@stacks/bitcoin-staking';
const rewards = await fetchRewards({ network: 'mainnet' }); // sats of sBTC, as a bigintNotes
get-rewardsreturns the contract's sBTC balance minustotal-sbtc-stakedandreserve-balance(get-rewards).It covers rewards already distributed to tranches and not yet claimed (fetchLastAccountedRewards) and rewards received since the last
calculate-rewards(fetchNewRewards).A non-2xx response throws an
Errorwhose message starts withError calling read-only function.and includes the status code and URL. If the node reports that the call failed, theErrormessage is the node'scause.
Signature
function fetchRewards(opts?: NetworkClientParam): Promise<bigint>;opts is a NetworkClientParam.
Returns
Promise<bigint>
Resolves to an amount of sBTC 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?