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
truewhen the grant exists andfalsewhen the contract returnsERR_SIGNER_KEY_GRANT_NOT_FOUND (u17), its only error (verify-signer-key-grant). Any other error code throws anErrorwhose message starts withverify-signer-key-grant returned (err u.grant-signer-keycreates the grant (grant-signer-key) andrevoke-signer-grantdeletes it (revoke-signer-grant).register-signerrequires 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
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
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?