Returns the current nonce of the smart account for a specified key.


import { publicClient } from "./client.ts"
import { getAccountNonce } from "permissionless"
const nonce = await getAccountNonce(publicClient, {
    address: "0x277F6C1D8d4faFA3d8DcC837489cd69d86c682BA",
    entryPoint: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
    key: 0n // optional
// 23n


  • Type: bigint

The current nonce of the smart account for the specified key (both the key and the sequence concatenated together into one uint256).



  • Type: Address

The address of the smart account.


  • Type: Address

The entry point address.

key (optional)

  • Type: bigint

The key of the nonce. Defaults to 0n.

Instead of sequential nonce, ERC-4337 implements a nonce mechanism that uses a single uint256 nonce value in the UserOperation, but treats it as two values, a 192-bit “key”, and a 64-bit “sequence”. These values are represented on-chain in the EntryPoint contract. For each key the sequence is validated and incremented sequentially and monotonically by the EntryPoint for each UserOperation, however a new key can be introduced with an arbitrary value at any point.