fetchSignerSetContainsForCycle
Checks whether a signer-manager is in the signer set for one reward cycle. Wraps the pox-5 read-only signer-set-contains-for-cycle, which reads the signer-set-ll-for-cycle map.
Usage
import { fetchPoxInfo, fetchSignerSetContainsForCycle } from '@stacks/bitcoin-staking';
async function inNextSignerSet(signer: string) {
const { rewardCycleId } = await fetchPoxInfo({ network: 'mainnet' });
return fetchSignerSetContainsForCycle({ signer, rewardCycle: rewardCycleId + 1, 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).Returns
truewhen the signer-manager has a node in the cycle's list (signer-set-contains-for-cycle).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 fetchSignerSetContainsForCycle(
opts: { signer: string; rewardCycle: number } & NetworkClientParam
): Promise<boolean>;opts is a NetworkClientParam plus signer and rewardCycle.
Returns
Promise<boolean>
Resolves to true if the signer-manager is in the cycle's signer set.
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?