getInstantLayerNonce
Read the Instant Layer replay nonce for a signer account — the counter every relayed operation’s replayAttackHeader.nonce must follow.
import { getInstantLayerNonce } from "@symmio/trading-core";
const current = await getInstantLayerNonce(config, { account: subAccount });
const operation = buildSignedOperation({ ...fields, nonce: current + 1n });One nonces(account) view on the InstantLayer. Nonces are sequential: an operation signs with the next nonce (current + 1n), and a batch must carry strictly consecutive nonces in signed-op order (current + 1n, current + 2n, …). Read it immediately before building operations — a stale value produces signatures the relayer’s simulation rejects — and never build two operations from one read; concurrent flows on the same account need serialization (the gasless dispatch does this internally).
The query factory exists for display purposes (e.g. showing an account’s operation count); a write path must always
call the action directly right before signing rather than trusting a cached value. This counter is unrelated to the
gasless wallet’s walletOperationNonces.
Parameters
accountAddressrequiredInstantLayer signer account (the sub-account the operation runs under).
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId.
Returns
Promise<bigint>nonce + 1n.Throws
SymmErrorwhen the chain is unsupported.- Viem read errors.