import { Address, PublicActions } from 'viem'; import { ENTRY_POINT_ADDRESS } from '@prex0/prex-structs'; const NonceManagerAbi = [ { inputs: [ { internalType: 'address', name: 'sender', type: 'address', }, { internalType: 'uint192', name: 'key', type: 'uint192', }, ], name: 'getNonce', outputs: [ { internalType: 'uint256', name: 'nonce', type: 'uint256', }, ], stateMutability: 'view', type: 'function', }, ] as const; export async function getERC4337Nonce( client: PublicActions, address: Address, key: bigint ) { const nonce = await client.readContract({ address: ENTRY_POINT_ADDRESS, abi: NonceManagerAbi, functionName: 'getNonce', args: [address, key], }); return nonce; }