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

fetchSignerSetItem

Reads a signer-manager's node in a reward cycle's signer set: its previous and next neighbors. Wraps the pox-5 read-only get-signer-set-item-for-cycle, which reads the signer-set-ll-for-cycle map.


Usage

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

async function neighbors(signer: string) {
  const { rewardCycleId: rewardCycle } = await fetchPoxInfo({ network: 'mainnet' });
  const item = await fetchSignerSetItem({ signer, rewardCycle, network: 'mainnet' });
  if (!item) return undefined; // not in the signer set
  return { prev: item.prev, next: item.next };
}

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 signer is not in the cycle's signer set (get-signer-set-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.

Reference Link


Signature

opts is a NetworkClientParam plus signer and rewardCycle.


Returns

Promise<{ prev: string | undefined; next: string | undefined } | undefined>

Resolves to the node, or undefined when the signer-manager is not in the set.

Field
Type
Meaning

prev

string or undefined

Previous signer-manager, undefined at the head

next

string or undefined

Next signer-manager, undefined at the tail


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?