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

fetchSignerSetLastItem

Reads the last signer-manager in a reward cycle's signer set. Wraps the pox-5 read-only get-signer-set-last-item-for-cycle, which reads the signer-set-ll-last-for-cycle map.


Usage

import { fetchPoxInfo, fetchSignerSetLastItem, fetchSignerSetPrevItem } from '@stacks/bitcoin-staking';

const { rewardCycleId: rewardCycle } = await fetchPoxInfo({ network: 'mainnet' });

// Newest first
const signers: string[] = [];
let signer = await fetchSignerSetLastItem({ rewardCycle, network: 'mainnet' });
while (signer) {
  signers.push(signer);
  signer = await fetchSignerSetPrevItem({ 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 undefined when the cycle's signer set is empty (get-signer-set-last-item-for-cycle).

  • 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.


Signature

opts is a NetworkClientParam plus rewardCycle.


Returns

Promise<string | undefined>

Resolves to the contract principal of the last signer-manager, or undefined.


Parameters

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?