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

fetchHasAnnouncedL1EarlyExit

Checks whether a staker has announced an L1 early exit for a protocol bond. Wraps the pox-5 read-only has-announced-l1-early-exit, which reads the protocol-bond-l1-early-exit-announced map.


Usage

import { fetchBondMembership, fetchHasAnnouncedL1EarlyExit } from '@stacks/bitcoin-staking';

async function hasAnnounced(staker: string) {
  const bond = await fetchBondMembership({ address: staker, network: 'mainnet' });
  if (!bond) return false;
  return fetchHasAnnouncedL1EarlyExit({ bondIndex: bond.bondIndex, staker, network: 'mainnet' });
}

Notes

  • announce-l1-early-exit sets the flag (announce-l1-early-exit) and reverts with ERR_L1_EARLY_EXIT_ALREADY_ANNOUNCED (u50) when it is already set (announce-l1-early-exit). Check it before buildAnnounceL1EarlyExit.

  • No pox-5 function clears the flag.

  • Returns false when the contract has no entry (has-announced-l1-early-exit).

  • 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 bondIndex and staker.


Returns

Promise<boolean>

Resolves to true if the staker has announced an L1 early exit for the bond.


Parameters

opts.bondIndex (required)

  • Type: number

Protocol bond index.

opts.staker (required)

  • Type: string

Stacks address of the staker.

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?