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

fetchVerifySignerKeyGrant

Checks whether an active grant authorizes a signer key for a signer-manager. Wraps the pox-5 read-only verify-signer-key-grant, which reads the signer-key-grants map.


Usage

import { fetchSignerInfo, fetchVerifySignerKeyGrant } from '@stacks/bitcoin-staking';

async function grantActive(signerManager: string) {
  const info = await fetchSignerInfo({ signerManager, network: 'mainnet' });
  if (!info) return false;
  return fetchVerifySignerKeyGrant({ signerKey: info.signerKey, signerManager, network: 'mainnet' });
}

Notes

  • Returns true when the grant exists and false when the contract returns ERR_SIGNER_KEY_GRANT_NOT_FOUND (u17), its only error (verify-signer-key-grant). Any other error code throws an Error whose message starts with verify-signer-key-grant returned (err u.

  • grant-signer-key creates the grant (grant-signer-key) and revoke-signer-grant deletes it (revoke-signer-grant). register-signer requires it (register-signer). Per the contract comment, every new-stake entry point checks it again, so a revoked grant stops the signer-manager from accepting new stake (revoke-signer-grant).

  • 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 signerKey and signerManager.


Returns

Promise<boolean>

Resolves to true if the grant is active.


Parameters

opts.signerKey (required)

  • Type: Uint8Array | string

Compressed secp256k1 public key, 33 bytes, as bytes or hex.

opts.signerManager (required)

  • Type: string

Contract principal of the signer-manager, in the form <address>.<contract-name>. pox-5 keys signer state by this principal.

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?