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

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 bigint

Notes

  • get-rewards returns the contract's sBTC balance minus total-sbtc-staked and reserve-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 Error whose message starts with Error calling read-only function. and includes the status code and URL. If the node reports that the call failed, the Error message is the node's cause.

Reference Link


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?