fetchSignerKeyGrantUsed
Checks whether a signer-key grant with a given auth ID has already been consumed. Reads the pox-5 used-signer-key-grants map directly through the node's /v2/map_entry endpoint.
Usage
import { fetchSignerKeyGrantUsed } from '@stacks/bitcoin-staking';
async function authIdUsed(signerKey: string, signerManager: string, authId: number) {
return fetchSignerKeyGrantUsed({ signerKey, signerManager, authId, network: 'mainnet' });
}Notes
grant-signer-keyrecords each(signer-key, signer-manager, auth-id)triple and reverts withERR_SIGNER_KEY_GRANT_USED (u12)when the triple is already recorded (grant-signer-key). Check it before buildGrantSignerKey and pick an unusedauthId.revoke-signer-grantdeletes only thesigner-key-grantsentry (revoke-signer-grant), so an auth ID stays used after a revocation.A non-2xx response, or a response without data, throws an
Errorwhose message starts withError fetching map entry for map "used-signer-key-grants".
Signature
function fetchSignerKeyGrantUsed(
opts: {
signerKey: Uint8Array | string;
signerManager: string;
authId: IntegerType;
} & NetworkClientParam
): Promise<boolean>;opts is a NetworkClientParam plus signerKey, signerManager and authId.
Returns
Promise<boolean>
Resolves to true if the triple has been used.
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.authId (required)
Type:
IntegerType
Auth ID of the grant.
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?