EVMSmartWallet
Smart wallet interface for EVM chains enhanced with Crossmint capabilities.
Core functionality is exposed via viem clients within the client
property of the class.
Constructors
new EVMSmartWallet()
new EVMSmartWallet(
crossmintService
,accountClient
,publicClient
,chain
,logger
):EVMSmartWallet
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
crossmintService | CrossmintWalletService | undefined | - |
accountClient | object | undefined | - |
accountClient.account | SmartAccount <EntryPoint > | undefined | The Account of the Client. |
accountClient.batch ? | object | undefined | Flags for batch settings. |
accountClient.batch.multicall ? | boolean | object | undefined | Toggle to enable eth_call multicall aggregation. |
accountClient.cacheTime | number | undefined | Time (in ms) that cached data will remain in memory. |
accountClient.ccipRead ? | false | object | undefined | CCIP Read configuration. |
accountClient.chain | Chain | undefined | Chain for the client. |
accountClient.deployContract | <TAbi , TChainOverride >(args ) => Promise <`0x${string}`> | undefined | Deploys a contract to the network, given bytecode and constructor arguments. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/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...', }) |
accountClient.extend | <client >(fn ) => Client <HttpTransport , Chain , SmartAccount <EntryPoint >, BundlerRpcSchema <EntryPoint >, { [K in string | number | symbol]: client[K] } & SmartAccountActions <EntryPoint , Chain , SmartAccount <EntryPoint >>> | undefined | - |
accountClient.key | string | undefined | A key for the client. |
accountClient.name | string | undefined | A name for the client. |
accountClient.pollingInterval | number | undefined | Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. |
accountClient.prepareUserOperationRequest | <TTransport >(args , stateOverrides ?) => Promise <object | object > | undefined | - |
accountClient.request | EIP1193RequestFn <BundlerRpcSchema <EntryPoint >> | undefined | Request function wrapped with friendly error handling |
accountClient.sendTransaction | <TChainOverride >(args ) => Promise <`0x${string}`> | undefined | Creates, signs, and sends a new transaction to the network. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/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, }) |
accountClient.sendTransactions | (args ) => Promise <`0x${string}`> | undefined | Creates, signs, and sends a new transaction to the network. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/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 }, { to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234', value: 10000000000000000n }) // 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 }, { to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234', value: 10000000000000000n }]) |
accountClient.sendUserOperation | <TTransport >(args ) => Promise <`0x${string}`> | undefined | - |
accountClient.signMessage | (args ) => Promise <`0x${string}`> | undefined | 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.html - 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', }) |
accountClient.signTypedData | <TTypedData , TPrimaryType >(args ) => Promise <`0x${string}`> | undefined | 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.html - 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!', }, }) |
accountClient.transport | TransportConfig <"http" , EIP1193RequestFn > & object | undefined | The RPC transport |
accountClient.type | string | undefined | The type of client. |
accountClient.uid | string | undefined | A unique ID for the client. |
accountClient.writeContract | <TAbi , TFunctionName , TArgs , TChainOverride >(args ) => Promise <`0x${string}`> | undefined | Executes a write function on a contract. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/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) |
publicClient | object | undefined | - |
publicClient.account | undefined | undefined | The Account of the Client. |
publicClient.batch ? | object | undefined | Flags for batch settings. |
publicClient.batch.multicall ? | boolean | object | undefined | Toggle to enable eth_call multicall aggregation. |
publicClient.cacheTime | number | undefined | Time (in ms) that cached data will remain in memory. |
publicClient.call | (parameters ) => Promise <CallReturnType > | undefined | 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 | object | undefined | CCIP Read configuration. |
publicClient.chain | undefined | Chain | undefined | Chain for the client. |
publicClient.createBlockFilter | () => Promise <object > | undefined | 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 >> | undefined | 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] }> | undefined | 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 <object > | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | 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.extend | <client >(fn ) => Client <HttpTransport , undefined | Chain , undefined , PublicRpcSchema , { [K in string | number | symbol]: client[K] } & PublicActions <HttpTransport , undefined | Chain >> | undefined | - |
publicClient.getBalance | (args ) => Promise <bigint > | undefined | 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 > | undefined | 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 <object > | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | Deprecated Use getCode instead. |
publicClient.getChainId | () => Promise <number > | undefined | 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 > | undefined | 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 >> | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | 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}`> | undefined | 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 > | undefined | 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 > | undefined | 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 >> | undefined | 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 >> | undefined | 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 > | undefined | 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 >> | undefined | 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/filters-and-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 > | undefined | 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 > | undefined | 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 <object | object | object | object > | undefined | 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 > | undefined | 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 > | undefined | 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 > | undefined | 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.key | string | undefined | A key for the client. |
publicClient.multicall | <contracts , allowFailure >(args ) => Promise <MulticallReturnType <contracts , allowFailure >> | undefined | 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.name | string | undefined | A name for the client. |
publicClient.pollingInterval | number | undefined | Frequency (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<(…)>> & Object, ParameterTypeToParameters<request[“parameters”] extends readonly PrepareTransactionRequestParameterType[] ? any[any][number] : “type” | “gas” | “nonce” | “blobVersionedHashes” | “fees” | “chainId”>> & (unknown extends request[“kzg”] ? Object : Pick<request, “kzg”>))[K] }> | undefined | 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 >> | undefined | 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.request | EIP1193RequestFn <PublicRpcSchema > | undefined | Request function wrapped with friendly error handling |
publicClient.sendRawTransaction | (args ) => Promise <`0x${string}`> | undefined | 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.simulateContract | <abi , functionName , args , chainOverride , accountOverride >(args ) => Promise <SimulateContractReturnType <abi , functionName , args , undefined | Chain , undefined | Account , chainOverride , accountOverride >> | undefined | 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.transport | TransportConfig <"http" , EIP1193RequestFn > & object | undefined | The RPC transport |
publicClient.type | string | undefined | The type of client. |
publicClient.uid | string | undefined | A unique ID for the client. |
publicClient.uninstallFilter | (args ) => Promise <boolean > | undefined | 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.verifyMessage | (args ) => Promise <boolean > | undefined | 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 > | undefined | 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 > | undefined | Verify that typed data was signed by the provided address. - Docs https://viem.sh/docs/actions/public/verifyTypedData |
publicClient.waitForTransactionReceipt | (args ) => Promise <TransactionReceipt > | undefined | 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 ) => WatchBlockNumberReturnType | undefined | Watches 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 ) => WatchBlocksReturnType | undefined | Watches 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 ) => WatchContractEventReturnType | undefined | Watches 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 ) => WatchEventReturnType | undefined | Watches 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 ) => WatchPendingTransactionsReturnType | undefined | Watches 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), }) |
chain | EVMSmartWalletChain | undefined | - |
logger | SDKLogger | scwLogger | - |
Returns
Defined in
packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:46
Properties
Property | Modifier | Type | Description | Defined in |
---|---|---|---|---|
chain | readonly | EVMSmartWalletChain | - | packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:28 |
client | readonly | object | viem clients that provide an interface for core wallet functionality. | packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:33 |
client.public | public | object | An interface to read onchain data, fetch transactions, retrieve account balances, etc. Corresponds to public JSON-RPC API methods. | packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:42 |
client.public.account | public | undefined | The Account of the Client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:63 |
client.public.batch? | public | object | Flags for batch settings. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:65 |
client.public.batch.multicall? | public | boolean | object | Toggle to enable eth_call multicall aggregation. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:19 |
client.public.cacheTime | public | number | Time (in ms) that cached data will remain in memory. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:67 |
client.public.call | public | (parameters : CallParameters <undefined | Chain >) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:83 |
client.public.ccipRead? | public | false | object | CCIP Read configuration. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:69 |
client.public.chain | public | undefined | Chain | Chain for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:71 |
client.public.createBlockFilter | public | () => Promise <object > | 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' } | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:103 |
client.public.createContractEventFilter | public | <abi , eventName , args , strict , fromBlock , toBlock >(args : CreateContractEventFilterParameters <abi , eventName , args , strict , fromBlock , toBlock >) => 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)']), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:124 |
client.public.createEventFilter | public | <abiEvent , abiEvents , strict , fromBlock , toBlock , _EventName , _Args >(args ?: CreateEventFilterParameters <abiEvent , abiEvents , strict , fromBlock , toBlock , _EventName , _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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:146 |
client.public.createPendingTransactionFilter | public | () => Promise <object > | 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' } | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:166 |
client.public.estimateContractGas | public | <chain , abi , functionName , args >(args : EstimateContractGasParameters <abi , functionName , args , chain >) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:193 |
client.public.estimateFeesPerGas | public | <chainOverride , type >(args ?: EstimateFeesPerGasParameters <undefined | Chain , chainOverride , type >) => Promise <EstimateFeesPerGasReturnType > | 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: ... } | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:631 |
client.public.estimateGas | public | (args : EstimateGasParameters <undefined | Chain >) => 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'), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:217 |
client.public.estimateMaxPriorityFeePerGas | public | <chainOverride >(args ?: object ) => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:823 |
client.public.extend | public | <client >(fn : (client ) => client ) => Client <Transport , undefined | Chain , undefined , PublicRpcSchema , { [K in string | number | symbol]: client[K] } & PublicActions <Transport , undefined | Chain >> | - | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:59 |
client.public.getBalance | public | (args : GetBalanceParameters ) => 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) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:252 |
client.public.getBlobBaseFee | public | () => 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() | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:273 |
client.public.getBlock | public | <includeTransactions , blockTag >(args ?: GetBlockParameters <includeTransactions , blockTag >) => Promise <object > | 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() | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:296 |
client.public.getBlockNumber | public | (args ?: GetBlockNumberParameters ) => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:318 |
client.public.getBlockTransactionCount | public | (args ?: GetBlockTransactionCountParameters ) => 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() | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:340 |
client.public.getBytecode | public | (args : GetCodeParameters ) => Promise <GetCodeReturnType > | Deprecated Use getCode instead. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:342 |
client.public.getChainId | public | () => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:362 |
client.public.getCode | public | (args : GetCodeParameters ) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:384 |
client.public.getContractEvents | public | <abi , eventName , strict , fromBlock , toBlock >(args : GetContractEventsParameters <abi , eventName , strict , fromBlock , toBlock >) => 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' }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:410 |
client.public.getEip712Domain | public | (args : GetEip712DomainParameters ) => 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: [], // } | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:443 |
client.public.getEnsAddress | public | (args : object ) => 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' | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:472 |
client.public.getEnsAvatar | public | (args : object ) => 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' | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:501 |
client.public.getEnsName | public | (args : object ) => 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' | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:527 |
client.public.getEnsResolver | public | (args : object ) => 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' | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:556 |
client.public.getEnsText | public | (args : object ) => 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' | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:586 |
client.public.getFeeHistory | public | (args : GetFeeHistoryParameters ) => 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], }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:609 |
client.public.getFilterChanges | public | <filterType , abi , eventName , strict , fromBlock , toBlock >(args : GetFilterChangesParameters <filterType , abi , eventName , strict , fromBlock , toBlock >) => 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 }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:710 |
client.public.getFilterLogs | public | <abi , eventName , strict , fromBlock , toBlock >(args : GetFilterLogsParameters <abi , eventName , strict , fromBlock , toBlock >) => 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 }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:737 |
client.public.getGasPrice | public | () => 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() | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:756 |
client.public.getLogs | public | <abiEvent , abiEvents , strict , fromBlock , toBlock >(args ?: GetLogsParameters <abiEvent , abiEvents , strict , fromBlock , toBlock >) => 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/filters-and-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() | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:777 |
client.public.getProof | public | (args : GetProofParameters ) => 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...'], }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:802 |
client.public.getStorageAt | public | (args : GetStorageAtParameters ) => 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:847 |
client.public.getTransaction | public | <blockTag >(args : GetTransactionParameters <blockTag >) => Promise <object | object | object | object > | 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:870 |
client.public.getTransactionConfirmations | public | (args : GetTransactionConfirmationsParameters <undefined | Chain >) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:893 |
client.public.getTransactionCount | public | (args : GetTransactionCountParameters ) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:915 |
client.public.getTransactionReceipt | public | (args : GetTransactionReceiptParameters ) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:938 |
client.public.key | public | string | A key for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:73 |
client.public.multicall | public | <contracts , allowFailure >(args : MulticallParameters <contracts , allowFailure >) => 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' }] | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:976 |
client.public.name | public | string | A name for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:75 |
client.public.pollingInterval | public | number | Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:77 |
client.public.prepareTransactionRequest | public | <request , chainOverride , accountOverride >(args : PrepareTransactionRequestParameters <undefined | Chain , undefined | Account , chainOverride , accountOverride , request >) => Promise <{ [K in string | number | symbol]: (UnionRequiredBy<Extract<(…) & (…) & (…), (…) extends (…) ? (…) : (…)> & Object, ParameterTypeToParameters<(…)[(…)] extends readonly (…)[] ? (…)[(…)] : (…) | (…) | (…) | (…) | (…) | (…)>> & (unknown extends request[“kzg”] ? Object : 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, }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1015 |
client.public.readContract | public | <abi , functionName , args >(args : ReadContractParameters <abi , functionName , 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1047 |
client.public.request | public | EIP1193RequestFn <PublicRpcSchema > | Request function wrapped with friendly error handling | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:79 |
client.public.sendRawTransaction | public | (args : SendRawTransactionParameters ) => 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' }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1072 |
client.public.simulateContract | public | <abi , functionName , args , chainOverride , accountOverride >(args : SimulateContractParameters <abi , functionName , args , undefined | Chain , chainOverride , accountOverride >) => Promise <SimulateContractReturnType <abi , functionName , args , undefined | Chain , undefined | Account , 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1103 |
client.public.transport | public | TransportConfig <string , EIP1193RequestFn > & Record <string , any > | The RPC transport | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:81 |
client.public.type | public | string | The type of client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:83 |
client.public.uid | public | string | A unique ID for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:85 |
client.public.uninstallFilter | public | (args : UninstallFilterParameters ) => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1157 |
client.public.verifyMessage | public | (args : object ) => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1114 |
client.public.verifySiweMessage | public | (args : object ) => 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 | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1125 |
client.public.verifyTypedData | public | (args : VerifyTypedDataParameters ) => Promise <boolean > | Verify that typed data was signed by the provided address. - Docs https://viem.sh/docs/actions/public/verifyTypedData | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1134 |
client.public.waitForTransactionReceipt | public | (args : WaitForTransactionReceiptParameters <undefined | Chain >) => 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', }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1196 |
client.public.watchBlockNumber | public | (args : WatchBlockNumberParameters ) => WatchBlockNumberReturnType | Watches 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1221 |
client.public.watchBlocks | public | <includeTransactions , blockTag >(args : WatchBlocksParameters <Transport , undefined | Chain , includeTransactions , blockTag >) => WatchBlocksReturnType | Watches 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1246 |
client.public.watchContractEvent | public | <abi , eventName , strict >(args : WatchContractEventParameters <abi , eventName , strict , Transport >) => WatchContractEventReturnType | Watches 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1276 |
client.public.watchEvent | public | <abiEvent , abiEvents , strict >(args : WatchEventParameters <abiEvent , abiEvents , strict , Transport >) => WatchEventReturnType | Watches 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1308 |
client.public.watchPendingTransactions | public | (args : WatchPendingTransactionsParameters <Transport >) => WatchPendingTransactionsReturnType | Watches 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), }) | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/decorators/public.d.ts:1337 |
client.wallet | public | object | An interface to interact with the smart wallet, execute transactions, sign messages, etc. | packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:37 |
client.wallet.account | public | SmartAccount <EntryPoint > | The Account of the Client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:63 |
client.wallet.batch? | public | object | Flags for batch settings. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:65 |
client.wallet.batch.multicall? | public | boolean | object | Toggle to enable eth_call multicall aggregation. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:19 |
client.wallet.cacheTime | public | number | Time (in ms) that cached data will remain in memory. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:67 |
client.wallet.ccipRead? | public | false | object | CCIP Read configuration. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:69 |
client.wallet.chain | public | Chain | Chain for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:71 |
client.wallet.deployContract | public | <TAbi , TChainOverride >(args : { [K in string | number | symbol]: DeployContractParameters<TAbi, Chain, SmartAccount<EntryPoint>, TChainOverride>[K] }) => Promise <`0x${string}`> | Deploys a contract to the network, given bytecode and constructor arguments. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/contract/deployContract.html - Examples: https://stackblitz.com/github/wagmi-dev/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...', }) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:226 |
client.wallet.extend | public | <client >(fn : (client ) => client ) => Client <HttpTransport , Chain , SmartAccount <EntryPoint >, BundlerRpcSchema <EntryPoint >, { [K in string | number | symbol]: client[K] } & SmartAccountActions <EntryPoint , Chain , SmartAccount <EntryPoint >>> | - | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:59 |
client.wallet.key | public | string | A key for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:73 |
client.wallet.name | public | string | A name for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:75 |
client.wallet.pollingInterval | public | number | Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:77 |
client.wallet.prepareUserOperationRequest | public | <TTransport >(args : object , stateOverrides ?: StateOverrides ) => Promise <object | object > | - | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:276 |
client.wallet.request | public | EIP1193RequestFn <BundlerRpcSchema <EntryPoint >> | Request function wrapped with friendly error handling | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:79 |
client.wallet.sendTransaction | public | <TChainOverride >(args : SendTransactionParameters <Chain , SmartAccount <EntryPoint >, TChainOverride >) => Promise <`0x${string}`> | Creates, signs, and sends a new transaction to the network. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/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, }) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:56 |
client.wallet.sendTransactions | public | (args : object ) => Promise <`0x${string}`> | Creates, signs, and sends a new transaction to the network. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/actions/wallet/sendTransaction.html - Examples: https://stackblitz.com/github/wagmi-dev/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 }, { to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234', value: 10000000000000000n }) // 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 }, { to: '0x61897970c51812dc3a010c7d01b50e0d17dc1234', value: 10000000000000000n }]) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:327 |
client.wallet.sendUserOperation | public | <TTransport >(args : object ) => Promise <`0x${string}`> | - | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:277 |
client.wallet.signMessage | public | (args : SignMessageParameters <SmartAccount <EntryPoint >>) => 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.html - 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', }) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:100 |
client.wallet.signTypedData | public | <TTypedData , TPrimaryType >(args : SignTypedDataParameters <TTypedData , TPrimaryType , SmartAccount <EntryPoint >>) => 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.html - 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!', }, }) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:197 |
client.wallet.transport | public | TransportConfig <"http" , EIP1193RequestFn > & object | The RPC transport | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:81 |
client.wallet.type | public | string | The type of client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:83 |
client.wallet.uid | public | string | A unique ID for the client. | node_modules/.pnpm/viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4/node_modules/viem/_types/clients/createClient.d.ts:85 |
client.wallet.writeContract | public | <TAbi , TFunctionName , TArgs , TChainOverride >(args : WriteContractParameters <TAbi , TFunctionName , TArgs , Chain , SmartAccount <EntryPoint >, TChainOverride >) => Promise <`0x${string}`> | Executes a write function on a contract. This function also allows you to sponsor this transaction if sender is a smartAccount - Docs: https://viem.sh/docs/contract/writeContract.html - Examples: https://stackblitz.com/github/wagmi-dev/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) | node_modules/.pnpm/permissionless@0.1.36_viem@2.17.5_bufferutil@4.0.7_typescript@5.5.3_utf-8-validate@5.0.10_zod@3.22.4_/node_modules/permissionless/_types/clients/decorators/smartAccount.d.ts:275 |
Accessors
address
get
address(): `0x${string}`
The address of the smart wallet.
Returns
`0x${string}`
Defined in
packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:64
Methods
executeContract()
executeContract<
TAbi
,TFunctionName
,TArgs
>(__namedParameters
):Promise
<`0x${string}`>
Sends a contract call transaction and returns the hash of a confirmed transaction.
Type Parameters
Type Parameter | Default type |
---|---|
TAbi extends Abi | readonly unknown [] | - |
TFunctionName extends string | ContractFunctionName <TAbi , "nonpayable" | "payable" > |
TArgs extends unknown | ContractFunctionArgs <TAbi , "nonpayable" | "payable" , TFunctionName > |
Parameters
Parameter | Type |
---|---|
__namedParameters | Omit <WriteContractParameters <TAbi , TFunctionName , TArgs >, "account" | "chain" > & object |
Returns
Promise
<`0x${string}`>
The transaction hash.
Throws
SendTransactionError
if the transaction fails to send. Contains the error thrown by the viem client.
Throws
SendTransactionExecutionRevertedError
, a subclass of SendTransactionError
if the transaction fails due to a contract execution error.
Passing a typed ABI:
Example
Defined in
packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:160
nfts()
nfts():
Promise
<any
>
Returns
Promise
<any
>
A list of NFTs owned by the wallet.
Defined in
packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:123
transferToken()
transferToken(
toAddress
,config
):Promise
<string
>
Parameters
Parameter | Type |
---|---|
toAddress | string |
config | TransferType |
Returns
Promise
<string
>
The transaction hash.
Defined in
packages/client/wallets/smart-wallet/src/blockchain/wallets/EVMSmartWallet.ts:71