Skip to content

Classes

FinanceClient

Defined in: packages/tokens/src/index.ts:31

Constructors

Constructor
ts
new FinanceClient(publicClient, walletClient): FinanceClient;

Defined in: packages/tokens/src/index.ts:32

Parameters
ParameterTypeDescription
publicClient{ account: undefined; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; call: (parameters) => Promise<CallReturnType>; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; createAccessList: (parameters) => Promise<{ accessList: AccessList; gasUsed: bigint; }>; createBlockFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${string}`]; ReturnType: `0x${string}`[] | RpcLog[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${string}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${string}`]; ReturnType: boolean; }]>; type: "block"; }>; createContractEventFilter: <abi, eventName, args, strict, fromBlock, toBlock>(args) => Promise<CreateContractEventFilterReturnType<abi, eventName, args, strict, fromBlock, toBlock>>; createEventFilter: <abiEvent, abiEvents, strict, fromBlock, toBlock, _EventName, _Args>(args?) => Promise<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>; createPendingTransactionFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${string}`]; ReturnType: `0x${string}`[] | RpcLog[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${string}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${string}`]; ReturnType: boolean; }]>; type: "transaction"; }>; estimateContractGas: <chain, abi, functionName, args>(args) => Promise<bigint>; estimateFeesPerGas: <chainOverride, type>(args?) => Promise<EstimateFeesPerGasReturnType<type>>; estimateGas: (args) => Promise<bigint>; estimateMaxPriorityFeePerGas: <chainOverride>(args?) => Promise<bigint>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, Chain | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getBalance: (args) => Promise<bigint>; getBlobBaseFee: () => Promise<bigint>; getBlock: <includeTransactions, blockTag>(args?) => Promise<{ baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; extraData: `0x${string}`; gasLimit: bigint; gasUsed: bigint; hash: blockTag extends "pending" ? null : `0x${string}`; logsBloom: blockTag extends "pending" ? null : `0x${string}`; miner: `0x${string}`; mixHash: `0x${string}`; nonce: blockTag extends "pending" ? null : `0x${string}`; number: blockTag extends "pending" ? null : bigint; parentBeaconBlockRoot?: `0x${string}`; parentHash: `0x${string}`; receiptsRoot: `0x${string}`; sealFields: `0x${string}`[]; sha3Uncles: `0x${string}`; size: bigint; stateRoot: `0x${string}`; timestamp: bigint; totalDifficulty: bigint | null; transactions: includeTransactions extends true ? ( | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; })[] : `0x${string}`[]; transactionsRoot: `0x${string}`; uncles: `0x${string}`[]; withdrawals?: Withdrawal[]; withdrawalsRoot?: `0x${string}`; }>; getBlockNumber: (args?) => Promise<bigint>; getBlockTransactionCount: (args?) => Promise<number>; getBytecode: (args) => Promise<GetCodeReturnType>; getChainId: () => Promise<number>; getCode: (args) => Promise<GetCodeReturnType>; getContractEvents: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getEip712Domain: (args) => Promise<GetEip712DomainReturnType>; getEnsAddress: (args) => Promise<GetEnsAddressReturnType>; getEnsAvatar: (args) => Promise<GetEnsAvatarReturnType>; getEnsName: (args) => Promise<GetEnsNameReturnType>; getEnsResolver: (args) => Promise<`0x${string}`>; getEnsText: (args) => Promise<GetEnsTextReturnType>; getFeeHistory: (args) => Promise<GetFeeHistoryReturnType>; getFilterChanges: <filterType, abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterChangesReturnType<filterType, abi, eventName, strict, fromBlock, toBlock>>; getFilterLogs: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getGasPrice: () => Promise<bigint>; getLogs: <abiEvent, abiEvents, strict, fromBlock, toBlock>(args?) => Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>>; getProof: (args) => Promise<GetProofReturnType>; getStorageAt: (args) => Promise<GetStorageAtReturnType>; getTransaction: <blockTag>(args) => Promise< | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; }>; getTransactionConfirmations: (args) => Promise<bigint>; getTransactionCount: (args) => Promise<number>; getTransactionReceipt: (args) => Promise<TransactionReceipt>; key: string; multicall: <contracts, allowFailure>(args) => Promise<MulticallReturnType<contracts, allowFailure>>; name: string; pollingInterval: number; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; readContract: <abi, functionName, args>(args) => Promise<ReadContractReturnType<abi, functionName, args>>; request: EIP1193RequestFn<PublicRpcSchema>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; simulate: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateBlocks: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateCalls: <calls>(args) => Promise<SimulateCallsReturnType<calls>>; simulateContract: <abi, functionName, args, chainOverride, accountOverride>(args) => Promise<SimulateContractReturnType<abi, functionName, args, Chain | undefined, Account | undefined, chainOverride, accountOverride>>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; uninstallFilter: (args) => Promise<boolean>; verifyHash: (args) => Promise<boolean>; verifyMessage: (args) => Promise<boolean>; verifySiweMessage: (args) => Promise<boolean>; verifyTypedData: (args) => Promise<boolean>; waitForTransactionReceipt: (args) => Promise<TransactionReceipt>; watchBlockNumber: (args) => WatchBlockNumberReturnType; watchBlocks: <includeTransactions, blockTag>(args) => WatchBlocksReturnType; watchContractEvent: <abi, eventName, strict>(args) => WatchContractEventReturnType; watchEvent: <abiEvent, abiEvents, strict>(args) => WatchEventReturnType; watchPendingTransactions: (args) => WatchPendingTransactionsReturnType; }-
publicClient.accountundefinedThe Account of the Client.
publicClient.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
publicClient.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
publicClient.cacheTimenumberTime (in ms) that cached data will remain in memory.
publicClient.call(parameters) => Promise<CallReturnType>Executes a new message call immediately without submitting a transaction to the network. - Docs: https://viem.sh/docs/actions/public/call - JSON-RPC Methods: eth_call Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const data = await client.call({ account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', })
publicClient.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
publicClient.chainChain | undefinedChain for the client.
publicClient.createAccessList(parameters) => Promise<{ accessList: AccessList; gasUsed: bigint; }>Creates an EIP-2930 access list that you can include in a transaction. - Docs: https://viem.sh/docs/actions/public/createAccessList - JSON-RPC Methods: eth_createAccessList Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const data = await client.createAccessList({ data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', })
publicClient.createBlockFilter() => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${string}`]; ReturnType: `0x${string}`[] | RpcLog[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${string}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${string}`]; ReturnType: boolean; }]>; type: "block"; }>Creates a Filter to listen for new block hashes that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createBlockFilter - JSON-RPC Methods: eth_newBlockFilter Example import { createPublicClient, createBlockFilter, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await createBlockFilter(client) // { id: "0x345a6572337856574a76364e457a4366", type: 'block' }
publicClient.createContractEventFilter<abi, eventName, args, strict, fromBlock, toBlock>(args) => Promise<CreateContractEventFilterReturnType<abi, eventName, args, strict, fromBlock, toBlock>>Creates a Filter to retrieve event logs that can be used with getFilterChanges or getFilterLogs. - Docs: https://viem.sh/docs/contract/createContractEventFilter Example import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createContractEventFilter({ abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']), })
publicClient.createEventFilter<abiEvent, abiEvents, strict, fromBlock, toBlock, _EventName, _Args>(args?) => Promise<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>Creates a Filter to listen for new events that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createEventFilter - JSON-RPC Methods: eth_newFilter Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2', })
publicClient.createPendingTransactionFilter() => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${string}`]; ReturnType: `0x${string}`[] | RpcLog[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${string}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${string}`]; ReturnType: boolean; }]>; type: "transaction"; }>Creates a Filter to listen for new pending transaction hashes that can be used with getFilterChanges. - Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter - JSON-RPC Methods: eth_newPendingTransactionFilter Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createPendingTransactionFilter() // { id: "0x345a6572337856574a76364e457a4366", type: 'transaction' }
publicClient.estimateContractGas<chain, abi, functionName, args>(args) => Promise<bigint>Estimates the gas required to successfully execute a contract write function call. - Docs: https://viem.sh/docs/contract/estimateContractGas Remarks Internally, uses a Public Client to call the estimateGas action with ABI-encoded data. Example import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gas = await client.estimateContractGas({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint() public']), functionName: 'mint', account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', })
publicClient.estimateFeesPerGas<chainOverride, type>(args?) => Promise<EstimateFeesPerGasReturnType<type>>Returns an estimate for the fees per gas for a transaction to be included in the next block. - Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const maxPriorityFeePerGas = await client.estimateFeesPerGas() // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }
publicClient.estimateGas(args) => Promise<bigint>Estimates the gas necessary to complete a transaction without submitting it to the network. - Docs: https://viem.sh/docs/actions/public/estimateGas - JSON-RPC Methods: eth_estimateGas Example import { createPublicClient, http, parseEther } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gasEstimate = await client.estimateGas({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
publicClient.estimateMaxPriorityFeePerGas<chainOverride>(args?) => Promise<bigint>Returns an estimate for the max priority fee per gas (in wei) for a transaction to be included in the next block. - Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas() // 10000000n
publicClient.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
publicClient.extend<client>(fn) => Client<Transport, Chain | undefined, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, Chain | undefined>>-
publicClient.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
publicClient.getBalance(args) => Promise<bigint>Returns the balance of an address in wei. - Docs: https://viem.sh/docs/actions/public/getBalance - JSON-RPC Methods: eth_getBalance Remarks You can convert the balance to ether units with formatEther. const balance = await getBalance(client, { address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', blockTag: 'safe' }) const balanceAsEther = formatEther(balance) // "6.942" Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const balance = await client.getBalance({ address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // 10000000000000000000000n (wei)
publicClient.getBlobBaseFee() => Promise<bigint>Returns the base fee per blob gas in wei. - Docs: https://viem.sh/docs/actions/public/getBlobBaseFee - JSON-RPC Methods: eth_blobBaseFee Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { getBlobBaseFee } from 'viem/public' const client = createPublicClient({ chain: mainnet, transport: http(), }) const blobBaseFee = await client.getBlobBaseFee()
publicClient.getBlock<includeTransactions, blockTag>(args?) => Promise<{ baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; extraData: `0x${string}`; gasLimit: bigint; gasUsed: bigint; hash: blockTag extends "pending" ? null : `0x${string}`; logsBloom: blockTag extends "pending" ? null : `0x${string}`; miner: `0x${string}`; mixHash: `0x${string}`; nonce: blockTag extends "pending" ? null : `0x${string}`; number: blockTag extends "pending" ? null : bigint; parentBeaconBlockRoot?: `0x${string}`; parentHash: `0x${string}`; receiptsRoot: `0x${string}`; sealFields: `0x${string}`[]; sha3Uncles: `0x${string}`; size: bigint; stateRoot: `0x${string}`; timestamp: bigint; totalDifficulty: bigint | null; transactions: includeTransactions extends true ? ( | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; })[] : `0x${string}`[]; transactionsRoot: `0x${string}`; uncles: `0x${string}`[]; withdrawals?: Withdrawal[]; withdrawalsRoot?: `0x${string}`; }>Returns information about a block at a block number, hash, or tag. - Docs: https://viem.sh/docs/actions/public/getBlock - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks - JSON-RPC Methods: - Calls eth_getBlockByNumber for blockNumber & blockTag. - Calls eth_getBlockByHash for blockHash. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const block = await client.getBlock()
publicClient.getBlockNumber(args?) => Promise<bigint>Returns the number of the most recent block seen. - Docs: https://viem.sh/docs/actions/public/getBlockNumber - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks - JSON-RPC Methods: eth_blockNumber Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const blockNumber = await client.getBlockNumber() // 69420n
publicClient.getBlockTransactionCount(args?) => Promise<number>Returns the number of Transactions at a block number, hash, or tag. - Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount - JSON-RPC Methods: - Calls eth_getBlockTransactionCountByNumber for blockNumber & blockTag. - Calls eth_getBlockTransactionCountByHash for blockHash. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const count = await client.getBlockTransactionCount()
publicClient.getBytecode(args) => Promise<GetCodeReturnType>Deprecated Use getCode instead.
publicClient.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const chainId = await client.getChainId() // 1
publicClient.getCode(args) => Promise<GetCodeReturnType>Retrieves the bytecode at an address. - Docs: https://viem.sh/docs/contract/getCode - JSON-RPC Methods: eth_getCode Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const code = await client.getCode({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', })
publicClient.getContractEvents<abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>Returns a list of event logs emitted by a contract. - Docs: https://viem.sh/docs/actions/public/getContractEvents - JSON-RPC Methods: eth_getLogs Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { wagmiAbi } from './abi' const client = createPublicClient({ chain: mainnet, transport: http(), }) const logs = await client.getContractEvents(client, { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: wagmiAbi, eventName: 'Transfer' })
publicClient.getEip712Domain(args) => Promise<GetEip712DomainReturnType>Reads the EIP-712 domain from a contract, based on the ERC-5267 specification. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const domain = await client.getEip712Domain({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', }) // { // domain: { // name: 'ExampleContract', // version: '1', // chainId: 1, // verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // }, // fields: '0x0f', // extensions: [], // }
publicClient.getEnsAddress(args) => Promise<GetEnsAddressReturnType>Gets address for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAddress - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens Remarks Calls resolve(bytes, bytes) on ENS Universal Resolver Contract. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensAddress = await client.getEnsAddress({ name: normalize('wevm.eth'), }) // '0xd2135CfB216b74109775236E36d4b433F1DF507B'
publicClient.getEnsAvatar(args) => Promise<GetEnsAvatarReturnType>Gets the avatar of an ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsAvatar - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens Remarks Calls getEnsText with key set to 'avatar'. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensAvatar = await client.getEnsAvatar({ name: normalize('wevm.eth'), }) // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'
publicClient.getEnsName(args) => Promise<GetEnsNameReturnType>Gets primary name for specified address. - Docs: https://viem.sh/docs/ens/actions/getEnsName - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens Remarks Calls reverse(bytes) on ENS Universal Resolver Contract to "reverse resolve" the address to the primary ENS name. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const ensName = await client.getEnsName({ address: '0xd2135CfB216b74109775236E36d4b433F1DF507B', }) // 'wevm.eth'
publicClient.getEnsResolver(args) => Promise<`0x${string}`>Gets resolver for ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens Remarks Calls findResolver(bytes) on ENS Universal Resolver Contract to retrieve the resolver of an ENS name. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const resolverAddress = await client.getEnsResolver({ name: normalize('wevm.eth'), }) // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'
publicClient.getEnsText(args) => Promise<GetEnsTextReturnType>Gets a text record for specified ENS name. - Docs: https://viem.sh/docs/ens/actions/getEnsResolver - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens Remarks Calls resolve(bytes, bytes) on ENS Universal Resolver Contract. Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to normalize ENS names with UTS-46 normalization before passing them to getEnsAddress. You can use the built-in normalize function for this. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { normalize } from 'viem/ens' const client = createPublicClient({ chain: mainnet, transport: http(), }) const twitterRecord = await client.getEnsText({ name: normalize('wevm.eth'), key: 'com.twitter', }) // 'wevm_dev'
publicClient.getFeeHistory(args) => Promise<GetFeeHistoryReturnType>Returns a collection of historical gas information. - Docs: https://viem.sh/docs/actions/public/getFeeHistory - JSON-RPC Methods: eth_feeHistory Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const feeHistory = await client.getFeeHistory({ blockCount: 4, rewardPercentiles: [25, 75], })
publicClient.getFilterChanges<filterType, abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterChangesReturnType<filterType, abi, eventName, strict, fromBlock, toBlock>>Returns a list of logs or hashes based on a Filter since the last time it was called. - Docs: https://viem.sh/docs/actions/public/getFilterChanges - JSON-RPC Methods: eth_getFilterChanges Remarks A Filter can be created from the following actions: - createBlockFilter - createContractEventFilter - createEventFilter - createPendingTransactionFilter Depending on the type of filter, the return value will be different: - If the filter was created with createContractEventFilter or createEventFilter, it returns a list of logs. - If the filter was created with createPendingTransactionFilter, it returns a list of transaction hashes. - If the filter was created with createBlockFilter, it returns a list of block hashes. Examples // Blocks import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createBlockFilter() const hashes = await client.getFilterChanges({ filter }) // Contract Events import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createContractEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']), eventName: 'Transfer', }) const logs = await client.getFilterChanges({ filter }) // Raw Events import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'), }) const logs = await client.getFilterChanges({ filter }) // Transactions import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createPendingTransactionFilter() const hashes = await client.getFilterChanges({ filter })
publicClient.getFilterLogs<abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>>Returns a list of event logs since the filter was created. - Docs: https://viem.sh/docs/actions/public/getFilterLogs - JSON-RPC Methods: eth_getFilterLogs Remarks getFilterLogs is only compatible with event filters. Example import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const filter = await client.createEventFilter({ address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'), }) const logs = await client.getFilterLogs({ filter })
publicClient.getGasPrice() => Promise<bigint>Returns the current price of gas (in wei). - Docs: https://viem.sh/docs/actions/public/getGasPrice - JSON-RPC Methods: eth_gasPrice Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const gasPrice = await client.getGasPrice()
publicClient.getLogs<abiEvent, abiEvents, strict, fromBlock, toBlock>(args?) => Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>>Returns a list of event logs matching the provided parameters. - Docs: https://viem.sh/docs/actions/public/getLogs - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs - JSON-RPC Methods: eth_getLogs Example import { createPublicClient, http, parseAbiItem } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const logs = await client.getLogs()
publicClient.getProof(args) => Promise<GetProofReturnType>Returns the account and storage values of the specified account including the Merkle-proof. - Docs: https://viem.sh/docs/actions/public/getProof - JSON-RPC Methods: - Calls eth_getProof Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const block = await client.getProof({ address: '0x...', storageKeys: ['0x...'], })
publicClient.getStorageAt(args) => Promise<GetStorageAtReturnType>Returns the value from a storage slot at a given address. - Docs: https://viem.sh/docs/contract/getStorageAt - JSON-RPC Methods: eth_getStorageAt Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { getStorageAt } from 'viem/contract' const client = createPublicClient({ chain: mainnet, transport: http(), }) const code = await client.getStorageAt({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', slot: toHex(0), })
publicClient.getTransaction<blockTag>(args) => Promise< | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; }>Returns information about a Transaction given a hash or block identifier. - Docs: https://viem.sh/docs/actions/public/getTransaction - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions - JSON-RPC Methods: eth_getTransactionByHash Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transaction = await client.getTransaction({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
publicClient.getTransactionConfirmations(args) => Promise<bigint>Returns the number of blocks passed (confirmations) since the transaction was processed on a block. - Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions - JSON-RPC Methods: eth_getTransactionConfirmations Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const confirmations = await client.getTransactionConfirmations({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
publicClient.getTransactionCount(args) => Promise<number>Returns the number of Transactions an Account has broadcast / sent. - Docs: https://viem.sh/docs/actions/public/getTransactionCount - JSON-RPC Methods: eth_getTransactionCount Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionCount = await client.getTransactionCount({ address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
publicClient.getTransactionReceipt(args) => Promise<TransactionReceipt>Returns the Transaction Receipt given a Transaction hash. - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions - JSON-RPC Methods: eth_getTransactionReceipt Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionReceipt = await client.getTransactionReceipt({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
publicClient.keystringA key for the client.
publicClient.multicall<contracts, allowFailure>(args) => Promise<MulticallReturnType<contracts, allowFailure>>Similar to readContract, but batches up multiple functions on a contract in a single RPC call via the multicall3 contract. - Docs: https://viem.sh/docs/contract/multicall Example import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const abi = parseAbi([ 'function balanceOf(address) view returns (uint256)', 'function totalSupply() view returns (uint256)', ]) const result = await client.multicall({ contracts: [ { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi, functionName: 'balanceOf', args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'], }, { address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi, functionName: 'totalSupply', }, ], }) // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]
publicClient.namestringA name for the client.
publicClient.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
publicClient.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
publicClient.readContract<abi, functionName, args>(args) => Promise<ReadContractReturnType<abi, functionName, args>>Calls a read-only function on a contract, and returns the response. - Docs: https://viem.sh/docs/contract/readContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_reading-contracts Remarks A "read-only" function (constant function) on a Solidity contract is denoted by a view or pure keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas. Internally, uses a Public Client to call the call action with ABI-encoded data. Example import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' import { readContract } from 'viem/contract' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.readContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function balanceOf(address) view returns (uint256)']), functionName: 'balanceOf', args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'], }) // 424122n
publicClient.requestEIP1193RequestFn<PublicRpcSchema>Request function wrapped with friendly error handling
publicClient.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
publicClient.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
publicClient.simulate<calls>(args) => Promise<SimulateBlocksReturnType<calls>>Deprecated Use simulateBlocks instead.
publicClient.simulateBlocks<calls>(args) => Promise<SimulateBlocksReturnType<calls>>Simulates a set of calls on block(s) with optional block and state overrides. Example import { createPublicClient, http, parseEther } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.simulateBlocks({ blocks: [{ blockOverrides: { number: 69420n, }, calls: [{ { account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929', data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), }, }], stateOverrides: [{ address: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929', balance: parseEther('10'), }], }] })
publicClient.simulateCalls<calls>(args) => Promise<SimulateCallsReturnType<calls>>Simulates a set of calls. Example import { createPublicClient, http, parseEther } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.simulateCalls({ account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929', calls: [{ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), }, ] })
publicClient.simulateContract<abi, functionName, args, chainOverride, accountOverride>(args) => Promise<SimulateContractReturnType<abi, functionName, args, Chain | undefined, Account | undefined, chainOverride, accountOverride>>Simulates/validates a contract interaction. This is useful for retrieving return data and revert reasons of contract write functions. - Docs: https://viem.sh/docs/contract/simulateContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts Remarks This function does not require gas to execute and does not change the state of the blockchain. It is almost identical to readContract, but also supports contract write functions. Internally, uses a Public Client to call the call action with ABI-encoded data. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const result = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32) view returns (uint32)']), functionName: 'mint', args: ['69420'], account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
publicClient.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
publicClient.typestringThe type of client.
publicClient.uidstringA unique ID for the client.
publicClient.uninstallFilter(args) => Promise<boolean>Destroys a Filter that was created from one of the following Actions: - createBlockFilter - createEventFilter - createPendingTransactionFilter - Docs: https://viem.sh/docs/actions/public/uninstallFilter - JSON-RPC Methods: eth_uninstallFilter Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' import { createPendingTransactionFilter, uninstallFilter } from 'viem/public' const filter = await client.createPendingTransactionFilter() const uninstalled = await client.uninstallFilter({ filter }) // true
publicClient.verifyHash(args) => Promise<boolean>Verify that a hash was signed by the provided address. - Docs https://viem.sh/docs/actions/public/verifyHash
publicClient.verifyMessage(args) => Promise<boolean>Verify that a message was signed by the provided address. Compatible with Smart Contract Accounts & Externally Owned Accounts via ERC-6492. - Docs https://viem.sh/docs/actions/public/verifyMessage
publicClient.verifySiweMessage(args) => Promise<boolean>Verifies EIP-4361 formatted message was signed. Compatible with Smart Contract Accounts & Externally Owned Accounts via ERC-6492. - Docs https://viem.sh/docs/siwe/actions/verifySiweMessage
publicClient.verifyTypedData(args) => Promise<boolean>Verify that typed data was signed by the provided address. - Docs https://viem.sh/docs/actions/public/verifyTypedData
publicClient.waitForTransactionReceipt(args) => Promise<TransactionReceipt>Waits for the Transaction to be included on a Block (one confirmation), and then returns the Transaction Receipt. If the Transaction reverts, then the action will throw an error. - Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - Polls eth_getTransactionReceipt on each block until it has been processed. - If a Transaction has been replaced: - Calls eth_getBlockByNumber and extracts the transactions - Checks if one of the Transactions is a replacement - If so, calls eth_getTransactionReceipt. Remarks The waitForTransactionReceipt action additionally supports Replacement detection (e.g. sped up Transactions). Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce. There are 3 types of Transaction Replacement reasons: - repriced: The gas price has been modified (e.g. different maxFeePerGas) - cancelled: The Transaction has been cancelled (e.g. value === 0n) - replaced: The Transaction has been replaced (e.g. different value or data) Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const transactionReceipt = await client.waitForTransactionReceipt({ hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d', })
publicClient.watchBlockNumber(args) => WatchBlockNumberReturnTypeWatches and returns incoming block numbers. - Docs: https://viem.sh/docs/actions/public/watchBlockNumber - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks - JSON-RPC Methods: - When poll: true, calls eth_blockNumber on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newHeads" event. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchBlockNumber({ onBlockNumber: (blockNumber) => console.log(blockNumber), })
publicClient.watchBlocks<includeTransactions, blockTag>(args) => WatchBlocksReturnTypeWatches and returns information for incoming blocks. - Docs: https://viem.sh/docs/actions/public/watchBlocks - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks - JSON-RPC Methods: - When poll: true, calls eth_getBlockByNumber on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newHeads" event. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchBlocks({ onBlock: (block) => console.log(block), })
publicClient.watchContractEvent<abi, eventName, strict>(args) => WatchContractEventReturnTypeWatches and returns emitted contract event logs. - Docs: https://viem.sh/docs/contract/watchContractEvent Remarks This Action will batch up all the event logs found within the pollingInterval, and invoke them via onLogs. watchContractEvent will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter), then watchContractEvent will fall back to using getLogs instead. Example import { createPublicClient, http, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = client.watchContractEvent({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']), eventName: 'Transfer', args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' }, onLogs: (logs) => console.log(logs), })
publicClient.watchEvent<abiEvent, abiEvents, strict>(args) => WatchEventReturnTypeWatches and returns emitted Event Logs. - Docs: https://viem.sh/docs/actions/public/watchEvent - JSON-RPC Methods: - RPC Provider supports eth_newFilter: - Calls eth_newFilter to create a filter (called on initialize). - On a polling interval, it will call eth_getFilterChanges. - RPC Provider does not support eth_newFilter: - Calls eth_getLogs for each block between the polling interval. Remarks This Action will batch up all the Event Logs found within the pollingInterval, and invoke them via onLogs. watchEvent will attempt to create an Event Filter and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. eth_newFilter), then watchEvent will fall back to using getLogs instead. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = client.watchEvent({ onLogs: (logs) => console.log(logs), })
publicClient.watchPendingTransactions(args) => WatchPendingTransactionsReturnTypeWatches and returns pending transaction hashes. - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions - JSON-RPC Methods: - When poll: true - Calls eth_newPendingTransactionFilter to initialize the filter. - Calls eth_getFilterChanges on a polling interval. - When poll: false & WebSocket Transport, uses a WebSocket subscription via eth_subscribe and the "newPendingTransactions" event. Remarks This Action will batch up all the pending transactions found within the pollingInterval, and invoke them via onTransactions. Example import { createPublicClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createPublicClient({ chain: mainnet, transport: http(), }) const unwatch = await client.watchPendingTransactions({ onTransactions: (hashes) => console.log(hashes), })
walletClient{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
walletClient.accountAccount | undefinedThe Account of the Client.
walletClient.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
walletClient.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
walletClient.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
walletClient.cacheTimenumberTime (in ms) that cached data will remain in memory.
walletClient.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
walletClient.chainChain | undefinedChain for the client.
walletClient.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
walletClient.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
walletClient.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
walletClient.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
walletClient.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
walletClient.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
walletClient.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
walletClient.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
walletClient.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
walletClient.keystringA key for the client.
walletClient.namestringA name for the client.
walletClient.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
walletClient.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
walletClient.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
walletClient.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
walletClient.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
walletClient.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
walletClient.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
walletClient.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
walletClient.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
walletClient.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
walletClient.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
walletClient.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
walletClient.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
walletClient.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
walletClient.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
walletClient.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
walletClient.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
walletClient.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
walletClient.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
walletClient.typestringThe type of client.
walletClient.uidstringA unique ID for the client.
walletClient.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
walletClient.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
walletClient.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
walletClient.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
Returns

FinanceClient

Methods

approveAndStake()
ts
approveAndStake(amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:169

One-step stake: Approve (if needed) + Stake

Parameters
ParameterTypeDescription
amountbigintAmount of GToken to stake
Returns

Promise<`0x${string}`>

Transaction hash of the stake action

getAPNTsBalance()
ts
getAPNTsBalance(address): Promise<bigint>;

Defined in: packages/tokens/src/index.ts:153

Get aPNTs balance

Parameters
ParameterType
address`0x${string}`
Returns

Promise<bigint>

getCirculatingSupply()
ts
getCirculatingSupply(): Promise<{
  circulating: bigint;
  locked: bigint;
  total: bigint;
}>;

Defined in: packages/tokens/src/index.ts:207

Get circulating supply (total - locked)

Returns

Promise<{ circulating: bigint; locked: bigint; total: bigint; }>

getGTokenBalance()
ts
getGTokenBalance(address): Promise<bigint>;

Defined in: packages/tokens/src/index.ts:140

Get GToken balance

Parameters
ParameterType
address`0x${string}`
Returns

Promise<bigint>

getTokenomicsOverview()
ts
getTokenomicsOverview(): Promise<{
  circulatingSupply: bigint;
  stakingRatio: number;
  totalBurned: bigint;
  totalStaked: bigint;
  totalSupply: bigint;
}>;

Defined in: packages/tokens/src/index.ts:234

Get comprehensive tokenomics data

Returns

Promise<{ circulatingSupply: bigint; stakingRatio: number; totalBurned: bigint; totalStaked: bigint; totalSupply: bigint; }>

depositToEntryPoint()
ts
static depositToEntryPoint(
   wallet, 
   entryPoint, 
   paymaster, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:92

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
entryPoint`0x${string}`-
paymaster`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

depositToPaymaster()
ts
static depositToPaymaster(
   wallet, 
   paymaster, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:40

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
paymaster`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

depositViaTransferAndCall()
ts
static depositViaTransferAndCall(
   wallet, 
   token, 
   paymaster, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:51

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
token`0x${string}`-
paymaster`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

getEntryPointBalance()
ts
static getEntryPointBalance(
   client, 
   entryPoint, 
account): Promise<bigint>;

Defined in: packages/tokens/src/index.ts:104

Parameters
ParameterType
clientany
entryPoint`0x${string}`
account`0x${string}`
Returns

Promise<bigint>

Deprecated

Use instance methods instead

operatorDeposit()
ts
static operatorDeposit(
   wallet, 
   paymaster, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:114

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
paymaster`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

operatorNotifyDeposit()
ts
static operatorNotifyDeposit(
   wallet, 
   paymaster, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:125

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
paymaster`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

stakeGToken()
ts
static stakeGToken(
   wallet, 
   stakingAddr, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:70

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
stakingAddr`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

withdrawProtocolRevenue()
ts
static withdrawProtocolRevenue(
   wallet, 
   paymaster, 
   to, 
amount): Promise<`0x${string}`>;

Defined in: packages/tokens/src/index.ts:81

Parameters
ParameterTypeDescription
wallet{ account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }-
wallet.accountAccount | undefinedThe Account of the Client.
wallet.addChain(args) => Promise<void>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/addChain - JSON-RPC Methods: eth_addEthereumChain Example import { createWalletClient, custom } from 'viem' import { optimism } from 'viem/chains' const client = createWalletClient({ transport: custom(window.ethereum), }) await client.addChain({ chain: optimism })
wallet.batch?{ multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }Flags for batch settings.
wallet.batch.multicall?| boolean | { batchSize?: number; deployless?: boolean; wait?: number; }Toggle to enable eth_call multicall aggregation.
wallet.cacheTimenumberTime (in ms) that cached data will remain in memory.
wallet.ccipRead?| false | { request?: (parameters) => Promise<`0x${string}`>; }CCIP Read configuration.
wallet.chainChain | undefinedChain for the client.
wallet.deployContract<abi, chainOverride>(args) => Promise<`0x${string}`>Deploys a contract to the network, given bytecode and constructor arguments. - Docs: https://viem.sh/docs/contract/deployContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts Example import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.deployContract({ abi: [], account: '0x…, bytecode: '0x608060405260405161083e38038061083e833981016040819052610...', })
wallet.experimental_blockTag?BlockTagDefault block tag to use for RPC requests.
wallet.extend<client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>-
wallet.fillTransaction<chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>Fills a transaction request with the necessary fields to be signed over. - Docs: https://viem.sh/docs/actions/public/fillTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const result = await client.fillTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: parseEther('1'), })
wallet.getAddresses() => Promise<GetAddressesReturnType>Returns a list of account addresses owned by the wallet or client. - Docs: https://viem.sh/docs/actions/wallet/getAddresses - JSON-RPC Methods: eth_accounts Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.getAddresses()
wallet.getCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Returns the status of a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/getCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await client.getCallsStatus({ id: '0xdeadbeef' })
wallet.getCapabilities<chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: "supported" | "ready" | "unsupported" }; paymasterService?: { supported: boolean }; unstable_addSubAccount?: { keyTypes: ((...) | (...) | (...) | (...))[]; supported: boolean }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any }>, number>)[K] }>Extract capabilities that a connected wallet supports (e.g. paymasters, session keys, etc). - Docs: https://viem.sh/docs/actions/wallet/getCapabilities - JSON-RPC Methods: wallet_getCapabilities Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const capabilities = await client.getCapabilities({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.getChainId() => Promise<number>Returns the chain ID associated with the current network. - Docs: https://viem.sh/docs/actions/public/getChainId - JSON-RPC Methods: eth_chainId Example import { createWalletClient, http } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const chainId = await client.getChainId() // 1
wallet.getPermissions() => Promise<GetPermissionsReturnType>Gets the wallets current permissions. - Docs: https://viem.sh/docs/actions/wallet/getPermissions - JSON-RPC Methods: wallet_getPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.getPermissions()
wallet.keystringA key for the client.
wallet.namestringA name for the client.
wallet.pollingIntervalnumberFrequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds.
wallet.prepareAuthorization(parameters) => Promise<PrepareAuthorizationReturnType>Prepares an EIP-7702 Authorization object for signing. This Action will fill the required fields of the Authorization object if they are not provided (e.g. nonce and chainId). With the prepared Authorization object, you can use signAuthorization to sign over the Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const authorization = await client.prepareAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.prepareTransactionRequest<request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<UnionOmit<(...), (...)> & ((...) extends (...) ? (...) : (...)) & ((...) extends (...) ? (...) : (...)), IsNever<(...)> extends true ? unknown : ExactPartial<(...)>> & { chainId?: number }, ParameterTypeToParameters<request["parameters"] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : "type" | "nonce" | "chainId" | "gas" | "fees" | "blobVersionedHashes">> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>Prepares a transaction request for signing. - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, })
wallet.requestEIP1193RequestFn<WalletRpcSchema>Request function wrapped with friendly error handling
wallet.requestAddresses() => Promise<RequestAddressesReturnType>Requests a list of accounts managed by a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestAddresses - JSON-RPC Methods: eth_requestAccounts Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses). This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts. Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const accounts = await client.requestAddresses()
wallet.requestPermissions(args) => Promise<RequestPermissionsReturnType>Requests permissions for a wallet. - Docs: https://viem.sh/docs/actions/wallet/requestPermissions - JSON-RPC Methods: wallet_requestPermissions Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const permissions = await client.requestPermissions({ eth_accounts: {} })
wallet.sendCalls<calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>Requests the connected wallet to send a batch of calls. - Docs: https://viem.sh/docs/actions/wallet/sendCalls - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const id = await client.sendCalls({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendCallsSync<calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Requests the connected wallet to send a batch of calls, and waits for the calls to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendCallsSync - JSON-RPC Methods: wallet_sendCalls Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const status = await client.sendCallsSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', calls: [ { data: '0xdeadbeef', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', }, { to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 69420n, }, ], })
wallet.sendRawTransaction(args) => Promise<`0x${string}`>Sends a signed transaction to the network - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction - JSON-RPC Method: eth_sendRawTransaction Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransaction } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendRawTransaction({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendRawTransactionSync(args) => Promise<TransactionReceipt>Sends a signed transaction to the network synchronously, and waits for the transaction to be included in a block. - Docs: https://viem.sh/docs/actions/wallet/sendRawTransactionSync - JSON-RPC Method: eth_sendRawTransactionSync Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' import { sendRawTransactionSync } from 'viem/wallet' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendRawTransactionSync({ serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33' })
wallet.sendTransaction<request, chainOverride>(args) => Promise<`0x${string}`>Creates, signs, and sends a new transaction to the network. - Docs: https://viem.sh/docs/actions/wallet/sendTransaction - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.sendTransaction({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const hash = await client.sendTransaction({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.sendTransactionSync<request, chainOverride>(args) => Promise<TransactionReceipt>Creates, signs, and sends a new transaction to the network synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/actions/wallet/sendTransactionSync - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions - JSON-RPC Methods: - JSON-RPC Accounts: eth_sendTransaction - Local Accounts: eth_sendRawTransaction Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.sendTransactionSync({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const receipt = await client.sendTransactionSync({ to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8', value: 1000000000000000000n, })
wallet.showCallsStatus(parameters) => Promise<void>Requests for the wallet to show information about a call batch that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/showCallsStatus - JSON-RPC Methods: wallet_showCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.showCallsStatus({ id: '0xdeadbeef' })
wallet.signAuthorization(parameters) => Promise<SignAuthorizationReturnType>Signs an EIP-7702 Authorization object. With the calculated signature, you can: - use verifyAuthorization to verify the signed Authorization object, - use recoverAuthorizationAddress to recover the signing address from the signed Authorization object. Examples import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ account: privateKeyToAccount('0x..'), contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signAuthorization({ contractAddress: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', })
wallet.signMessage(args) => Promise<`0x${string}`>Calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signMessage - JSON-RPC Methods: - JSON-RPC Accounts: personal_sign - Local Accounts: Signs locally. No JSON-RPC request. With the calculated signature, you can: - use verifyMessage to verify the signature, - use recoverMessageAddress to recover the signing address from a signature. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signMessage({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', message: 'hello world', }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signMessage({ message: 'hello world', })
wallet.signTransaction<chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never> extends "legacy" ? TransactionSerializedLegacy : never>>Signs a transaction. - Docs: https://viem.sh/docs/actions/wallet/signTransaction - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTransaction - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: custom(window.ethereum), }) const request = await client.prepareTransactionRequest({ to: '0x0000000000000000000000000000000000000000', value: 1n, }) const signature = await client.signTransaction(request)
wallet.signTypedData<typedData, primaryType>(args) => Promise<`0x${string}`>Signs typed data and calculates an Ethereum-specific signature in EIP-191 format: keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)). - Docs: https://viem.sh/docs/actions/wallet/signTypedData - JSON-RPC Methods: - JSON-RPC Accounts: eth_signTypedData_v4 - Local Accounts: Signs locally. No JSON-RPC request. Examples import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const signature = await client.signTypedData({ account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e', domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, }) // Account Hoisting import { createWalletClient, http } from 'viem' import { privateKeyToAccount } from 'viem/accounts' import { mainnet } from 'viem/chains' const client = createWalletClient({ account: privateKeyToAccount('0x…'), chain: mainnet, transport: http(), }) const signature = await client.signTypedData({ domain: { name: 'Ether Mail', version: '1', chainId: 1, verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC', }, types: { Person: [ { name: 'name', type: 'string' }, { name: 'wallet', type: 'address' }, ], Mail: [ { name: 'from', type: 'Person' }, { name: 'to', type: 'Person' }, { name: 'contents', type: 'string' }, ], }, primaryType: 'Mail', message: { from: { name: 'Cow', wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', }, to: { name: 'Bob', wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB', }, contents: 'Hello, Bob!', }, })
wallet.switchChain(args) => Promise<void>Switch the target chain in a wallet. - Docs: https://viem.sh/docs/actions/wallet/switchChain - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet, optimism } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) await client.switchChain({ id: optimism.id })
wallet.transportTransportConfig<string, EIP1193RequestFn> & Record<string, any>The RPC transport
wallet.typestringThe type of client.
wallet.uidstringA unique ID for the client.
wallet.waitForCallsStatus(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>Waits for the status & receipts of a call bundle that was sent via sendCalls. - Docs: https://viem.sh/docs/actions/wallet/waitForCallsStatus - JSON-RPC Methods: wallet_getCallsStatus Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { receipts, status } = await waitForCallsStatus(client, { id: '0xdeadbeef' })
wallet.watchAsset(args) => Promise<boolean>Adds an EVM chain to the wallet. - Docs: https://viem.sh/docs/actions/wallet/watchAsset - JSON-RPC Methods: eth_switchEthereumChain Example import { createWalletClient, custom } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const success = await client.watchAsset({ type: 'ERC20', options: { address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', decimals: 18, symbol: 'WETH', }, })
wallet.writeContract<abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>Executes a write function on a contract. - Docs: https://viem.sh/docs/contract/writeContract - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Examples import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const hash = await client.writeContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], }) // With Validation import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const { request } = await client.simulateContract({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], } const hash = await client.writeContract(request)
wallet.writeContractSync<abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>Executes a write function on a contract synchronously. Returns the transaction receipt. - Docs: https://viem.sh/docs/contract/writeContract A "write" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a Transaction is needed to be broadcast in order to change the state. Internally, uses a Wallet Client to call the sendTransaction action with ABI-encoded data. Warning: The write internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to simulate the contract write with contract.simulate before you execute it. Example import { createWalletClient, custom, parseAbi } from 'viem' import { mainnet } from 'viem/chains' const client = createWalletClient({ chain: mainnet, transport: custom(window.ethereum), }) const receipt = await client.writeContractSync({ address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', abi: parseAbi(['function mint(uint32 tokenId) nonpayable']), functionName: 'mint', args: [69420], })
paymaster`0x${string}`-
to`0x${string}`-
amountbigint-
Returns

Promise<`0x${string}`>

Deprecated

Use instance methods instead

Type Aliases

TokenActions

ts
type TokenActions = object;

Defined in: packages/core/src/actions/tokens.ts:5

Properties

tokenAddAutoApprovedSpender()
ts
tokenAddAutoApprovedSpender: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:38

Parameters
ParameterType
args{ account?: Account | Address; spender: Address; token: Address; }
args.account?Account | Address
args.spenderAddress
args.tokenAddress
Returns

Promise<Hash>

tokenAllowance()
ts
tokenAllowance: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:14

Parameters
ParameterType
args{ owner: Address; spender: Address; token: Address; }
args.ownerAddress
args.spenderAddress
args.tokenAddress
Returns

Promise<bigint>

tokenApprove()
ts
tokenApprove: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:13

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; spender: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.spenderAddress
args.tokenAddress
Returns

Promise<Hash>

tokenAutoApprovedSpenders()
ts
tokenAutoApprovedSpenders: (args) => Promise<boolean>;

Defined in: packages/core/src/actions/tokens.ts:66

Parameters
ParameterType
args{ spender: Address; token: Address; }
args.spenderAddress
args.tokenAddress
Returns

Promise<boolean>

tokenBalanceOf()
ts
tokenBalanceOf: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:8

Parameters
ParameterType
args{ account: Address; token: Address; }
args.accountAddress
args.tokenAddress
Returns

Promise<bigint>

tokenBurn()
ts
tokenBurn: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:18

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; token: Address; }
args.account?Account | Address
args.amountbigint
args.tokenAddress
Returns

Promise<Hash>

tokenBurnFrom()
ts
tokenBurnFrom: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:19

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; from: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.fromAddress
args.tokenAddress
Returns

Promise<Hash>

tokenBurnFromWithOpHash()
ts
tokenBurnFromWithOpHash: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:67

Parameters
ParameterType
args{ account: Address; amount: bigint; opHash: Hex; token: Address; userOpAccount?: Account | Address; }
args.accountAddress
args.amountbigint
args.opHashHex
args.tokenAddress
args.userOpAccount?Account | Address
Returns

Promise<Hash>

tokenCap()
ts
tokenCap: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:9

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenCommunityENS()
ts
tokenCommunityENS: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:52

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

tokenCommunityName()
ts
tokenCommunityName: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:51

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

tokenCommunityOwner()
ts
tokenCommunityOwner: (args) => Promise<Address>;

Defined in: packages/core/src/actions/tokens.ts:68

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<Address>

tokenCumulativeSpent()
ts
tokenCumulativeSpent: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:56

Parameters
ParameterType
args{ token: Address; user: Address; }
args.tokenAddress
args.userAddress
Returns

Promise<bigint>

tokenDebts()
ts
tokenDebts: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:57

Parameters
ParameterType
args{ token: Address; user: Address; }
args.tokenAddress
args.userAddress
Returns

Promise<bigint>

tokenDecimals()
ts
tokenDecimals: (args) => Promise<number>;

Defined in: packages/core/src/actions/tokens.ts:24

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<number>

tokenDEFAULT_SPENDING_LIMIT_APNTS()
ts
tokenDEFAULT_SPENDING_LIMIT_APNTS: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:74

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenDefaultSpendingLimitXPNTs()
ts
tokenDefaultSpendingLimitXPNTs: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:55

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenDOMAIN_SEPARATOR()
ts
tokenDOMAIN_SEPARATOR: (args) => Promise<Hex>;

Defined in: packages/core/src/actions/tokens.ts:61

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<Hex>

tokenEip712Domain()
ts
tokenEip712Domain: (args) => Promise<any>;

Defined in: packages/core/src/actions/tokens.ts:69

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<any>

tokenExchangeRate()
ts
tokenExchangeRate: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:53

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenFACTORY()
ts
tokenFACTORY: (args) => Promise<Address>;

Defined in: packages/core/src/actions/tokens.ts:44

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<Address>

tokenGetDebt()
ts
tokenGetDebt: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:33

Parameters
ParameterType
args{ token: Address; user: Address; }
args.tokenAddress
args.userAddress
Returns

Promise<bigint>

tokenGetDefaultSpendingLimitXPNTs()
ts
tokenGetDefaultSpendingLimitXPNTs: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:70

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenGetMetadata()
ts
tokenGetMetadata: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:71

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

tokenIsAutoApprovedSpender()
ts
tokenIsAutoApprovedSpender: (args) => Promise<boolean>;

Defined in: packages/core/src/actions/tokens.ts:40

Parameters
ParameterType
args{ spender: Address; token: Address; }
args.spenderAddress
args.tokenAddress
Returns

Promise<boolean>

tokenMint()
ts
tokenMint: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:17

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; to: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.toAddress
args.tokenAddress
Returns

Promise<Hash>

tokenName()
ts
tokenName: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:22

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

tokenNeedsApproval()
ts
tokenNeedsApproval: (args) => Promise<boolean>;

Defined in: packages/core/src/actions/tokens.ts:72

Parameters
ParameterType
args{ amount: bigint; owner: Address; spender: Address; token: Address; }
args.amountbigint
args.ownerAddress
args.spenderAddress
args.tokenAddress
Returns

Promise<boolean>

tokenNonces()
ts
tokenNonces: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:62

Parameters
ParameterType
args{ owner: Address; token: Address; }
args.ownerAddress
args.tokenAddress
Returns

Promise<bigint>

tokenOwner()
ts
tokenOwner: (args) => Promise<Address>;

Defined in: packages/core/src/actions/tokens.ts:27

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<Address>

tokenPermit()
ts
tokenPermit: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:63

Parameters
ParameterType
args{ account?: Account | Address; deadline: bigint; owner: Address; r: Hex; s: Hex; spender: Address; token: Address; v: number; value: bigint; }
args.account?Account | Address
args.deadlinebigint
args.ownerAddress
args.rHex
args.sHex
args.spenderAddress
args.tokenAddress
args.vnumber
args.valuebigint
Returns

Promise<Hash>

tokenRecordDebt()
ts
tokenRecordDebt: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:73

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; token: Address; user: Address; }
args.account?Account | Address
args.amountbigint
args.tokenAddress
args.userAddress
Returns

Promise<Hash>

tokenRemainingMintableSupply()
ts
tokenRemainingMintableSupply: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:10

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenRemoveAutoApprovedSpender()
ts
tokenRemoveAutoApprovedSpender: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:39

Parameters
ParameterType
args{ account?: Account | Address; spender: Address; token: Address; }
args.account?Account | Address
args.spenderAddress
args.tokenAddress
Returns

Promise<Hash>

tokenRenounceOwnership()
ts
tokenRenounceOwnership: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:29

Parameters
ParameterType
args{ account?: Account | Address; token: Address; }
args.account?Account | Address
args.tokenAddress
Returns

Promise<Hash>

tokenRepayDebt()
ts
tokenRepayDebt: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:34

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; token: Address; }
args.account?Account | Address
args.amountbigint
args.tokenAddress
Returns

Promise<Hash>

tokenSetPaymasterLimit()
ts
tokenSetPaymasterLimit: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:77

Parameters
ParameterType
args{ account?: Account | Address; limit: bigint; token: Address; user: Address; }
args.account?Account | Address
args.limitbigint
args.tokenAddress
args.userAddress
Returns

Promise<Hash>

tokenSetSuperPaymasterAddress()
ts
tokenSetSuperPaymasterAddress: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:78

Parameters
ParameterType
args{ account?: Account | Address; superPaymaster: Address; token: Address; }
args.account?Account | Address
args.superPaymasterAddress
args.tokenAddress
Returns

Promise<Hash>

tokenSpendingLimits()
ts
tokenSpendingLimits: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:54

Parameters
ParameterType
args{ token: Address; user: Address; }
args.tokenAddress
args.userAddress
Returns

Promise<bigint>

tokenSUPERPAYMASTER_ADDRESS()
ts
tokenSUPERPAYMASTER_ADDRESS: (args) => Promise<Address>;

Defined in: packages/core/src/actions/tokens.ts:43

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<Address>

tokenSymbol()
ts
tokenSymbol: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:23

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

tokenTotalSupply()
ts
tokenTotalSupply: (args) => Promise<bigint>;

Defined in: packages/core/src/actions/tokens.ts:7

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<bigint>

tokenTransfer()
ts
tokenTransfer: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:11

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; to: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.toAddress
args.tokenAddress
Returns

Promise<Hash>

tokenTransferAndCall()
ts
tokenTransferAndCall: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:35

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; data?: Hex; to: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.data?Hex
args.toAddress
args.tokenAddress
Returns

Promise<Hash>

tokenTransferCommunityOwnership()
ts
tokenTransferCommunityOwnership: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:48

Parameters
ParameterType
args{ account?: Account | Address; newOwner: Address; token: Address; }
args.account?Account | Address
args.newOwnerAddress
args.tokenAddress
Returns

Promise<Hash>

tokenTransferFrom()
ts
tokenTransferFrom: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:12

Parameters
ParameterType
args{ account?: Account | Address; amount: bigint; from: Address; to: Address; token: Address; }
args.account?Account | Address
args.amountbigint
args.fromAddress
args.toAddress
args.tokenAddress
Returns

Promise<Hash>

tokenTransferOwnership()
ts
tokenTransferOwnership: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:47

Parameters
ParameterType
args{ account?: Account | Address; newOwner: Address; token: Address; }
args.account?Account | Address
args.newOwnerAddress
args.tokenAddress
Returns

Promise<Hash>

tokenTransferTokenOwnership()
ts
tokenTransferTokenOwnership: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:28

Parameters
ParameterType
args{ account?: Account | Address; newOwner: Address; token: Address; }
args.account?Account | Address
args.newOwnerAddress
args.tokenAddress
Returns

Promise<Hash>

tokenUpdateExchangeRate()
ts
tokenUpdateExchangeRate: (args) => Promise<Hash>;

Defined in: packages/core/src/actions/tokens.ts:32

Parameters
ParameterType
args{ account?: Account | Address; newRate: bigint; token: Address; }
args.account?Account | Address
args.newRatebigint
args.tokenAddress
Returns

Promise<Hash>

tokenUsedOpHashes()
ts
tokenUsedOpHashes: (args) => Promise<boolean>;

Defined in: packages/core/src/actions/tokens.ts:58

Parameters
ParameterType
args{ hash: Hex; token: Address; }
args.hashHex
args.tokenAddress
Returns

Promise<boolean>

tokenVersion()
ts
tokenVersion: (args) => Promise<string>;

Defined in: packages/core/src/actions/tokens.ts:79

Parameters
ParameterType
args{ token: Address; }
args.tokenAddress
Returns

Promise<string>

Variables

CORE_ADDRESSES

ts
const CORE_ADDRESSES: object;

Defined in: packages/core/src/contract-addresses.ts:29

Core System Addresses

Type Declaration

NameTypeDefault valueDefined in
aPNTs`0x${string}`APNTS_ADDRESSpackages/core/src/contract-addresses.ts:35
dvtValidator`0x${string}`DVT_VALIDATOR_ADDRESSpackages/core/src/contract-addresses.ts:39
entryPoint`0x${string}`ENTRY_POINT_ADDRESSpackages/core/src/contract-addresses.ts:40
gToken`0x${string}`GTOKEN_ADDRESSpackages/core/src/contract-addresses.ts:31
gTokenStaking`0x${string}`GTOKEN_STAKING_ADDRESSpackages/core/src/contract-addresses.ts:32
mySBT`0x${string}`SBT_ADDRESSpackages/core/src/contract-addresses.ts:36
paymasterFactory`0x${string}`PAYMASTER_FACTORY_ADDRESSpackages/core/src/contract-addresses.ts:34
paymasterV4`0x${string}`-packages/core/src/contract-addresses.ts:38
registry`0x${string}`REGISTRY_ADDRESSpackages/core/src/contract-addresses.ts:30
reputationSystem`0x${string}`-packages/core/src/contract-addresses.ts:42
superPaymaster`0x${string}`SUPER_PAYMASTER_ADDRESSpackages/core/src/contract-addresses.ts:33
xPNTsFactory`0x${string}`XPNTS_FACTORY_ADDRESSpackages/core/src/contract-addresses.ts:41

GTokenABI

ts
const GTokenABI: any;

Defined in: packages/core/src/abis/index.ts:47


xPNTsFactoryABI

ts
const xPNTsFactoryABI: any;

Defined in: packages/core/src/abis/index.ts:57


xPNTsTokenABI

ts
const xPNTsTokenABI: any;

Defined in: packages/core/src/abis/index.ts:56

Functions

gTokenActions()

ts
function gTokenActions(): (client) => TokenActions;

Defined in: packages/core/src/actions/tokens.ts:87

Returns

ts
(client): TokenActions;
Parameters
ParameterType
client| { account: undefined; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; call: (parameters) => Promise<CallReturnType>; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; createAccessList: (parameters) => Promise<{ accessList: AccessList; gasUsed: bigint; }>; createBlockFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "block"; }>; createContractEventFilter: <abi, eventName, args, strict, fromBlock, toBlock>(args) => Promise<CreateContractEventFilterReturnType<abi, eventName, args, strict, fromBlock, toBlock>>; createEventFilter: <abiEvent, abiEvents, strict, fromBlock, toBlock, _EventName, _Args>(args?) => Promise<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>; createPendingTransactionFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "transaction"; }>; estimateContractGas: <chain, abi, functionName, args>(args) => Promise<bigint>; estimateFeesPerGas: <chainOverride, type>(args?) => Promise<EstimateFeesPerGasReturnType<type>>; estimateGas: (args) => Promise<bigint>; estimateMaxPriorityFeePerGas: <chainOverride>(args?) => Promise<bigint>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, Chain | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getBalance: (args) => Promise<bigint>; getBlobBaseFee: () => Promise<bigint>; getBlock: <includeTransactions, blockTag>(args?) => Promise<{ baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; extraData: `0x${string}`; gasLimit: bigint; gasUsed: bigint; hash: blockTag extends "pending" ? null : `0x${string}`; logsBloom: blockTag extends "pending" ? null : `0x${string}`; miner: `0x${string}`; mixHash: `0x${string}`; nonce: blockTag extends "pending" ? null : `0x${string}`; number: blockTag extends "pending" ? null : bigint; parentBeaconBlockRoot?: `0x${string}`; parentHash: `0x${string}`; receiptsRoot: `0x${string}`; sealFields: `0x${string}`[]; sha3Uncles: `0x${string}`; size: bigint; stateRoot: `0x${string}`; timestamp: bigint; totalDifficulty: bigint | null; transactions: includeTransactions extends true ? ( | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId?: ... | ...; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "legacy"; typeHex: ... | ...; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip2930"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip1559"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly ...[]; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip4844"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip7702"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; })[] : `0x${string}`[]; transactionsRoot: `0x${string}`; uncles: `0x${string}`[]; withdrawals?: Withdrawal[]; withdrawalsRoot?: `0x${string}`; }>; getBlockNumber: (args?) => Promise<bigint>; getBlockTransactionCount: (args?) => Promise<number>; getBytecode: (args) => Promise<GetCodeReturnType>; getChainId: () => Promise<number>; getCode: (args) => Promise<GetCodeReturnType>; getContractEvents: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getEip712Domain: (args) => Promise<GetEip712DomainReturnType>; getEnsAddress: (args) => Promise<GetEnsAddressReturnType>; getEnsAvatar: (args) => Promise<GetEnsAvatarReturnType>; getEnsName: (args) => Promise<GetEnsNameReturnType>; getEnsResolver: (args) => Promise<`0x${string}`>; getEnsText: (args) => Promise<GetEnsTextReturnType>; getFeeHistory: (args) => Promise<GetFeeHistoryReturnType>; getFilterChanges: <filterType, abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterChangesReturnType<filterType, abi, eventName, strict, fromBlock, toBlock>>; getFilterLogs: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getGasPrice: () => Promise<bigint>; getLogs: <abiEvent, abiEvents, strict, fromBlock, toBlock>(args?) => Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>>; getProof: (args) => Promise<GetProofReturnType>; getStorageAt: (args) => Promise<GetStorageAtReturnType>; getTransaction: <blockTag>(args) => Promise< | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; }>; getTransactionConfirmations: (args) => Promise<bigint>; getTransactionCount: (args) => Promise<number>; getTransactionReceipt: (args) => Promise<TransactionReceipt>; key: string; multicall: <contracts, allowFailure>(args) => Promise<MulticallReturnType<contracts, allowFailure>>; name: string; pollingInterval: number; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; readContract: <abi, functionName, args>(args) => Promise<ReadContractReturnType<abi, functionName, args>>; request: EIP1193RequestFn<PublicRpcSchema>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; simulate: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateBlocks: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateCalls: <calls>(args) => Promise<SimulateCallsReturnType<calls>>; simulateContract: <abi, functionName, args, chainOverride, accountOverride>(args) => Promise<SimulateContractReturnType<abi, functionName, args, Chain | undefined, Account | undefined, chainOverride, accountOverride>>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; uninstallFilter: (args) => Promise<boolean>; verifyHash: (args) => Promise<boolean>; verifyMessage: (args) => Promise<boolean>; verifySiweMessage: (args) => Promise<boolean>; verifyTypedData: (args) => Promise<boolean>; waitForTransactionReceipt: (args) => Promise<TransactionReceipt>; watchBlockNumber: (args) => WatchBlockNumberReturnType; watchBlocks: <includeTransactions, blockTag>(args) => WatchBlocksReturnType; watchContractEvent: <abi, eventName, strict>(args) => WatchContractEventReturnType; watchEvent: <abiEvent, abiEvents, strict>(args) => WatchEventReturnType; watchPendingTransactions: (args) => WatchPendingTransactionsReturnType; } | { account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: ...; paymasterService?: ...; unstable_addSubAccount?: ...; [key: ...]: ... }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }
Returns

TokenActions


tokenActions()

ts
function tokenActions(): (client) => TokenActions;

Defined in: packages/core/src/actions/tokens.ts:143

Returns

ts
(client): TokenActions;
Parameters
ParameterType
client| { account: undefined; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; call: (parameters) => Promise<CallReturnType>; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; createAccessList: (parameters) => Promise<{ accessList: AccessList; gasUsed: bigint; }>; createBlockFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "block"; }>; createContractEventFilter: <abi, eventName, args, strict, fromBlock, toBlock>(args) => Promise<CreateContractEventFilterReturnType<abi, eventName, args, strict, fromBlock, toBlock>>; createEventFilter: <abiEvent, abiEvents, strict, fromBlock, toBlock, _EventName, _Args>(args?) => Promise<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>; createPendingTransactionFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "transaction"; }>; estimateContractGas: <chain, abi, functionName, args>(args) => Promise<bigint>; estimateFeesPerGas: <chainOverride, type>(args?) => Promise<EstimateFeesPerGasReturnType<type>>; estimateGas: (args) => Promise<bigint>; estimateMaxPriorityFeePerGas: <chainOverride>(args?) => Promise<bigint>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, Chain | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getBalance: (args) => Promise<bigint>; getBlobBaseFee: () => Promise<bigint>; getBlock: <includeTransactions, blockTag>(args?) => Promise<{ baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; extraData: `0x${string}`; gasLimit: bigint; gasUsed: bigint; hash: blockTag extends "pending" ? null : `0x${string}`; logsBloom: blockTag extends "pending" ? null : `0x${string}`; miner: `0x${string}`; mixHash: `0x${string}`; nonce: blockTag extends "pending" ? null : `0x${string}`; number: blockTag extends "pending" ? null : bigint; parentBeaconBlockRoot?: `0x${string}`; parentHash: `0x${string}`; receiptsRoot: `0x${string}`; sealFields: `0x${string}`[]; sha3Uncles: `0x${string}`; size: bigint; stateRoot: `0x${string}`; timestamp: bigint; totalDifficulty: bigint | null; transactions: includeTransactions extends true ? ( | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId?: ... | ...; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "legacy"; typeHex: ... | ...; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip2930"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip1559"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly ...[]; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip4844"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip7702"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; })[] : `0x${string}`[]; transactionsRoot: `0x${string}`; uncles: `0x${string}`[]; withdrawals?: Withdrawal[]; withdrawalsRoot?: `0x${string}`; }>; getBlockNumber: (args?) => Promise<bigint>; getBlockTransactionCount: (args?) => Promise<number>; getBytecode: (args) => Promise<GetCodeReturnType>; getChainId: () => Promise<number>; getCode: (args) => Promise<GetCodeReturnType>; getContractEvents: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getEip712Domain: (args) => Promise<GetEip712DomainReturnType>; getEnsAddress: (args) => Promise<GetEnsAddressReturnType>; getEnsAvatar: (args) => Promise<GetEnsAvatarReturnType>; getEnsName: (args) => Promise<GetEnsNameReturnType>; getEnsResolver: (args) => Promise<`0x${string}`>; getEnsText: (args) => Promise<GetEnsTextReturnType>; getFeeHistory: (args) => Promise<GetFeeHistoryReturnType>; getFilterChanges: <filterType, abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterChangesReturnType<filterType, abi, eventName, strict, fromBlock, toBlock>>; getFilterLogs: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getGasPrice: () => Promise<bigint>; getLogs: <abiEvent, abiEvents, strict, fromBlock, toBlock>(args?) => Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>>; getProof: (args) => Promise<GetProofReturnType>; getStorageAt: (args) => Promise<GetStorageAtReturnType>; getTransaction: <blockTag>(args) => Promise< | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; }>; getTransactionConfirmations: (args) => Promise<bigint>; getTransactionCount: (args) => Promise<number>; getTransactionReceipt: (args) => Promise<TransactionReceipt>; key: string; multicall: <contracts, allowFailure>(args) => Promise<MulticallReturnType<contracts, allowFailure>>; name: string; pollingInterval: number; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; readContract: <abi, functionName, args>(args) => Promise<ReadContractReturnType<abi, functionName, args>>; request: EIP1193RequestFn<PublicRpcSchema>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; simulate: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateBlocks: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateCalls: <calls>(args) => Promise<SimulateCallsReturnType<calls>>; simulateContract: <abi, functionName, args, chainOverride, accountOverride>(args) => Promise<SimulateContractReturnType<abi, functionName, args, Chain | undefined, Account | undefined, chainOverride, accountOverride>>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; uninstallFilter: (args) => Promise<boolean>; verifyHash: (args) => Promise<boolean>; verifyMessage: (args) => Promise<boolean>; verifySiweMessage: (args) => Promise<boolean>; verifyTypedData: (args) => Promise<boolean>; waitForTransactionReceipt: (args) => Promise<TransactionReceipt>; watchBlockNumber: (args) => WatchBlockNumberReturnType; watchBlocks: <includeTransactions, blockTag>(args) => WatchBlocksReturnType; watchContractEvent: <abi, eventName, strict>(args) => WatchContractEventReturnType; watchEvent: <abiEvent, abiEvents, strict>(args) => WatchEventReturnType; watchPendingTransactions: (args) => WatchPendingTransactionsReturnType; } | { account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: ...; paymasterService?: ...; unstable_addSubAccount?: ...; [key: ...]: ... }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }
Returns

TokenActions


xPNTsFactoryActions()

ts
function xPNTsFactoryActions(address): (client) => XPNTsFactoryActions;

Defined in: packages/core/src/actions/factory.ts:121

Parameters

ParameterType
address`0x${string}`

Returns

ts
(client): XPNTsFactoryActions;
Parameters
ParameterType
client| { account: undefined; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; call: (parameters) => Promise<CallReturnType>; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; createAccessList: (parameters) => Promise<{ accessList: AccessList; gasUsed: bigint; }>; createBlockFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "block"; }>; createContractEventFilter: <abi, eventName, args, strict, fromBlock, toBlock>(args) => Promise<CreateContractEventFilterReturnType<abi, eventName, args, strict, fromBlock, toBlock>>; createEventFilter: <abiEvent, abiEvents, strict, fromBlock, toBlock, _EventName, _Args>(args?) => Promise<{ [K in string | number | symbol]: Filter<"event", abiEvents, _EventName, _Args, strict, fromBlock, toBlock>[K] }>; createPendingTransactionFilter: () => Promise<{ id: `0x${string}`; request: EIP1193RequestFn<readonly [{ Method: "eth_getFilterChanges"; Parameters: [`0x${(...)}`]; ReturnType: ...[] | ...[]; }, { Method: "eth_getFilterLogs"; Parameters: [`0x${(...)}`]; ReturnType: RpcLog[]; }, { Method: "eth_uninstallFilter"; Parameters: [`0x${(...)}`]; ReturnType: boolean; }]>; type: "transaction"; }>; estimateContractGas: <chain, abi, functionName, args>(args) => Promise<bigint>; estimateFeesPerGas: <chainOverride, type>(args?) => Promise<EstimateFeesPerGasReturnType<type>>; estimateGas: (args) => Promise<bigint>; estimateMaxPriorityFeePerGas: <chainOverride>(args?) => Promise<bigint>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, undefined, PublicRpcSchema, { [K in string | number | symbol]: client[K] } & PublicActions<Transport, Chain | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getBalance: (args) => Promise<bigint>; getBlobBaseFee: () => Promise<bigint>; getBlock: <includeTransactions, blockTag>(args?) => Promise<{ baseFeePerGas: bigint | null; blobGasUsed: bigint; difficulty: bigint; excessBlobGas: bigint; extraData: `0x${string}`; gasLimit: bigint; gasUsed: bigint; hash: blockTag extends "pending" ? null : `0x${string}`; logsBloom: blockTag extends "pending" ? null : `0x${string}`; miner: `0x${string}`; mixHash: `0x${string}`; nonce: blockTag extends "pending" ? null : `0x${string}`; number: blockTag extends "pending" ? null : bigint; parentBeaconBlockRoot?: `0x${string}`; parentHash: `0x${string}`; receiptsRoot: `0x${string}`; sealFields: `0x${string}`[]; sha3Uncles: `0x${string}`; size: bigint; stateRoot: `0x${string}`; timestamp: bigint; totalDifficulty: bigint | null; transactions: includeTransactions extends true ? ( | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId?: ... | ...; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "legacy"; typeHex: ... | ...; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice: bigint; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip2930"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip1559"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly ...[]; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip4844"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: ... extends ... ? ... : ...; blockNumber: ... extends ... ? ... : ...; chainId: number; from: `0x${(...)}`; gas: bigint; gasPrice?: undefined; hash: `0x${(...)}`; input: `0x${(...)}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${(...)}`; s: `0x${(...)}`; to: ... | ...; transactionIndex: ... extends ... ? ... : ...; type: "eip7702"; typeHex: ... | ...; v: bigint; value: bigint; yParity: number; })[] : `0x${string}`[]; transactionsRoot: `0x${string}`; uncles: `0x${string}`[]; withdrawals?: Withdrawal[]; withdrawalsRoot?: `0x${string}`; }>; getBlockNumber: (args?) => Promise<bigint>; getBlockTransactionCount: (args?) => Promise<number>; getBytecode: (args) => Promise<GetCodeReturnType>; getChainId: () => Promise<number>; getCode: (args) => Promise<GetCodeReturnType>; getContractEvents: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getEip712Domain: (args) => Promise<GetEip712DomainReturnType>; getEnsAddress: (args) => Promise<GetEnsAddressReturnType>; getEnsAvatar: (args) => Promise<GetEnsAvatarReturnType>; getEnsName: (args) => Promise<GetEnsNameReturnType>; getEnsResolver: (args) => Promise<`0x${string}`>; getEnsText: (args) => Promise<GetEnsTextReturnType>; getFeeHistory: (args) => Promise<GetFeeHistoryReturnType>; getFilterChanges: <filterType, abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterChangesReturnType<filterType, abi, eventName, strict, fromBlock, toBlock>>; getFilterLogs: <abi, eventName, strict, fromBlock, toBlock>(args) => Promise<GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>>; getGasPrice: () => Promise<bigint>; getLogs: <abiEvent, abiEvents, strict, fromBlock, toBlock>(args?) => Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>>; getProof: (args) => Promise<GetProofReturnType>; getStorageAt: (args) => Promise<GetStorageAtReturnType>; getTransaction: <blockTag>(args) => Promise< | { accessList?: undefined; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId?: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "legacy"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity?: undefined; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice: bigint; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas?: undefined; maxPriorityFeePerGas?: undefined; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip2930"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip1559"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList?: undefined; blobVersionedHashes: readonly `0x${string}`[]; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas: bigint; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip4844"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; } | { accessList: AccessList; authorizationList: SignedAuthorizationList; blobVersionedHashes?: undefined; blockHash: blockTag extends "pending" ? true : false extends true ? null : `0x${string}`; blockNumber: blockTag extends "pending" ? true : false extends true ? null : bigint; chainId: number; from: `0x${string}`; gas: bigint; gasPrice?: undefined; hash: `0x${string}`; input: `0x${string}`; maxFeePerBlobGas?: undefined; maxFeePerGas: bigint; maxPriorityFeePerGas: bigint; nonce: number; r: `0x${string}`; s: `0x${string}`; to: `0x${string}` | null; transactionIndex: blockTag extends "pending" ? true : false extends true ? null : number; type: "eip7702"; typeHex: `0x${string}` | null; v: bigint; value: bigint; yParity: number; }>; getTransactionConfirmations: (args) => Promise<bigint>; getTransactionCount: (args) => Promise<number>; getTransactionReceipt: (args) => Promise<TransactionReceipt>; key: string; multicall: <contracts, allowFailure>(args) => Promise<MulticallReturnType<contracts, allowFailure>>; name: string; pollingInterval: number; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; readContract: <abi, functionName, args>(args) => Promise<ReadContractReturnType<abi, functionName, args>>; request: EIP1193RequestFn<PublicRpcSchema>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; simulate: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateBlocks: <calls>(args) => Promise<SimulateBlocksReturnType<calls>>; simulateCalls: <calls>(args) => Promise<SimulateCallsReturnType<calls>>; simulateContract: <abi, functionName, args, chainOverride, accountOverride>(args) => Promise<SimulateContractReturnType<abi, functionName, args, Chain | undefined, Account | undefined, chainOverride, accountOverride>>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; uninstallFilter: (args) => Promise<boolean>; verifyHash: (args) => Promise<boolean>; verifyMessage: (args) => Promise<boolean>; verifySiweMessage: (args) => Promise<boolean>; verifyTypedData: (args) => Promise<boolean>; waitForTransactionReceipt: (args) => Promise<TransactionReceipt>; watchBlockNumber: (args) => WatchBlockNumberReturnType; watchBlocks: <includeTransactions, blockTag>(args) => WatchBlocksReturnType; watchContractEvent: <abi, eventName, strict>(args) => WatchContractEventReturnType; watchEvent: <abiEvent, abiEvents, strict>(args) => WatchEventReturnType; watchPendingTransactions: (args) => WatchPendingTransactionsReturnType; } | { account: Account | undefined; addChain: (args) => Promise<void>; batch?: { multicall?: | boolean | { batchSize?: number; deployless?: boolean; wait?: number; }; }; cacheTime: number; ccipRead?: | false | { request?: (parameters) => Promise<`0x${string}`>; }; chain: Chain | undefined; deployContract: <abi, chainOverride>(args) => Promise<`0x${string}`>; experimental_blockTag?: BlockTag; extend: <client>(fn) => Client<Transport, Chain | undefined, Account | undefined, WalletRpcSchema, { [K in string | number | symbol]: client[K] } & WalletActions<Chain | undefined, Account | undefined>>; fillTransaction: <chainOverride, accountOverride>(args) => Promise<FillTransactionReturnType<Chain | undefined, chainOverride>>; getAddresses: () => Promise<GetAddressesReturnType>; getCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; getCapabilities: <chainId>(parameters?) => Promise<{ [K in string | number | symbol]: (chainId extends number ? { atomic?: { status: ... }; paymasterService?: { supported: ... }; unstable_addSubAccount?: { keyTypes: ...; supported: ... }; [key: string]: any } : ChainIdToCapabilities<Capabilities<{ atomic?: ...; paymasterService?: ...; unstable_addSubAccount?: ...; [key: ...]: ... }>, number>)[K] }>; getChainId: () => Promise<number>; getPermissions: () => Promise<GetPermissionsReturnType>; key: string; name: string; pollingInterval: number; prepareAuthorization: (parameters) => Promise<PrepareAuthorizationReturnType>; prepareTransactionRequest: <request, chainOverride, accountOverride>(args) => Promise<{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(...), (...)> & { chainId?: ... }, ParameterTypeToParameters<(...) extends (...) ? (...) : (...)>> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K] }>; request: EIP1193RequestFn<WalletRpcSchema>; requestAddresses: () => Promise<RequestAddressesReturnType>; requestPermissions: (args) => Promise<RequestPermissionsReturnType>; sendCalls: <calls, chainOverride>(parameters) => Promise<{ capabilities?: { [key: string]: any; }; id: string; }>; sendCallsSync: <calls, chainOverride>(parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; sendRawTransaction: (args) => Promise<`0x${string}`>; sendRawTransactionSync: (args) => Promise<TransactionReceipt>; sendTransaction: <request, chainOverride>(args) => Promise<`0x${string}`>; sendTransactionSync: <request, chainOverride>(args) => Promise<TransactionReceipt>; showCallsStatus: (parameters) => Promise<void>; signAuthorization: (parameters) => Promise<SignAuthorizationReturnType>; signMessage: (args) => Promise<`0x${string}`>; signTransaction: <chainOverride, request>(args) => Promise<TransactionSerialized<GetTransactionType<request, | request extends LegacyProperties ? "legacy" : never | request extends EIP1559Properties ? "eip1559" : never | request extends EIP2930Properties ? "eip2930" : never | request extends EIP4844Properties ? "eip4844" : never | request extends EIP7702Properties ? "eip7702" : never | request["type"] extends string | undefined ? Extract<any[any], string> : never>, | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip1559" ? `0x02${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip2930" ? `0x01${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip4844" ? `0x03${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "eip7702" ? `0x04${string}` : never | GetTransactionType<request, | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ... | ... extends ... ? ... : ...> extends "legacy" ? TransactionSerializedLegacy : never>>; signTypedData: <typedData, primaryType>(args) => Promise<`0x${string}`>; switchChain: (args) => Promise<void>; transport: TransportConfig<string, EIP1193RequestFn> & Record<string, any>; type: string; uid: string; waitForCallsStatus: (parameters) => Promise<{ atomic: boolean; capabilities?: | { [key: string]: any; } | { [key: string]: any; }; chainId: number; id: string; receipts?: WalletCallReceipt<bigint, "success" | "reverted">[]; status: "success" | "pending" | "failure" | undefined; statusCode: number; version: string; }>; watchAsset: (args) => Promise<boolean>; writeContract: <abi, functionName, args, chainOverride>(args) => Promise<`0x${string}`>; writeContractSync: <abi, functionName, args, chainOverride>(args) => Promise<TransactionReceipt>; }
Returns

XPNTsFactoryActions

Released under the MIT License. | Last Updated: 2026-01-15 09:16