fetchSignerSetNextItem
Reads the signer-manager after a given one in a reward cycle's signer set. Wraps the pox-5 read-only get-signer-set-next-item-for-cycle, which reads the signer-set-ll-for-cycle map.
Usage
import { fetchPoxInfo, fetchSignerSetFirstItem, fetchSignerSetNextItem } from '@stacks/bitcoin-staking';
const { rewardCycleId: rewardCycle } = await fetchPoxInfo({ network: 'mainnet' });
const signers: string[] = [];
let signer = await fetchSignerSetFirstItem({ rewardCycle, network: 'mainnet' });
while (signer) {
signers.push(signer);
signer = await fetchSignerSetNextItem({ signer, rewardCycle, network: 'mainnet' });
}Notes
pox-5 stores each reward cycle's signer set as a doubly linked list of signer-manager principals (signer-set maps). A signer-manager is appended at the tail when the total STX staked to it for the cycle reaches 50,000 STX (
SIGNER_SET_MIN_USTX, 50,000,000,000 micro-STX) and is unlinked when that total falls below (SIGNER_SET_MIN_USTX, add-staker-to-signer-for-cycle, remove-staker-from-signer-for-cycle).Resolves to
undefinedat the tail of the list and whensigneris not in the set (get-signer-set-next-item-for-cycle). Use fetchSignerSetContainsForCycle to tell the two apart.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
opts is a NetworkClientParam plus signer and rewardCycle.
Returns
Promise<string | undefined>
Resolves to the contract principal of the next signer-manager, or undefined.
Parameters
opts.signer (required)
Type:
string
Contract principal of the signer-manager, in the form <address>.<contract-name>.
opts.rewardCycle (required)
Type:
number
Reward cycle to read.
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?