getGaslessWalletNonce
Read the GaslessLayer’s wallet-operation replay nonce — walletOperationNonces(owner, walletId, signerAccount), the counter behind gaslessWalletExecute signatures.
import { getGaslessWalletNonce } from "@symmio/trading-core";
const current = await getGaslessWalletNonce(config, { owner, walletId: 2n, account: subAccount });
// a wallet operation signs with current + 1nThis is a separate counter from the InstantLayer’s operation nonces (getInstantLayerNonce) — the two are not interchangeable. The value is the last nonce the wallet consumed for that signer account. Like every gasless nonce it is sequential: sign with nonce + 1, read immediately before signing, and never build two operations from one read. gaslessWalletExecute does all of this internally; reach for the raw read only when assembling wallet operations yourself.
One stream per wallet and signer account
Every (walletId, account) pair is its own nonce stream:
- Wallet
0keeps the original counter, keyed by the signer account alone, so it carries on from signatures made before the multi-wallet upgrade.ownerdoes not change the value. - Each positive id counts separately for its own wallet address. A nonce consumed on wallet
2never advances wallet0or wallet1.
account is the operation’s signerAccount.addr: the owner itself for an owner-signed call, or the sub-account a session key signs for. A sub-account therefore has its own counter, separate from the owner’s.
Parameters
ownerAddressrequiredThe owner the wallet belongs to: account itself for an owner-signed call, otherwise the owner of the sub-account
(or of a virtual account’s parent). Pass the owner’s address, never a GaslessWallet address. For a positive
walletId it selects whose wallet the stream belongs to; wallet 0’s value does not depend on it.
walletIdbigintdefault 0noptionalWhich of the owner’s wallets the operation executes from, from 0n through 2^256 - 1. 0n is the original
wallet.
accountAddressrequiredThe signer account the nonce is keyed under — the operation’s signerAccount.addr.
chainIdnumberoptionalTarget chain id. Defaults to the config’s defaultChainId.
Returns
Promise<bigint>The last wallet-operation nonce consumed on this stream. Sign with nonce + 1n.
Query options
import { getGaslessWalletNonceQueryOptions } from "@symmio/trading-core";
import { useQuery } from "@tanstack/react-query";
useQuery(getGaslessWalletNonceQueryOptions(config, { owner, walletId: 2n, account: subAccount }));An omitted walletId keys the same as 0n. Use the query to display a wallet’s state, never to sign from a cached value. React consumers use useGaslessWalletNonce, which useGaslessWalletExecute invalidates once an operation lands.
Throws
SymmError("validation", "GASLESS_WALLET_ID_INVALID")—walletIdis not abigintfrom0nthrough2^256 - 1(a JavaScriptnumberincluded). Thrown before any RPC call.SymmError("config", "GASLESS_NOT_CONFIGURED")/("config", "GASLESS_UNSUPPORTED_CONTRACTS_VERSION").- Viem read errors. A GaslessLayer that has not been upgraded to the multi-wallet interface reverts with empty data.