<!--
Sitemap:
- [Why Viem](/docs/introduction): A brief preamble on why we built Viem
- [Installation](/docs/installation)
- [Getting Started](/docs/getting-started): Get started with viem in just a few lines of code.
- [Platform Compatibility](/docs/compatibility): Platforms compatible with Viem
- [Frequently Asked Questions](/docs/faq)
- [Migration Guide](/docs/migration-guide)
- [Ethers v5 → viem Migration Guide](/docs/ethers-migration): Migrate from Ethers v5 to viem
- [TypeScript](/docs/typescript): TypeScript support for Viem
- [Error Handling](/docs/error-handling)
- [EIP-7702 Overview](/docs/eip7702): An Overview of EIP-7702
- [Contract Writes with EIP-7702](/docs/eip7702/contract-writes)
- [Sending Transactions with EIP-7702](/docs/eip7702/sending-transactions)
- [Blob Transactions](/docs/guides/blob-transactions): Sending your first Blob Transaction with Viem.
- [Introduction to Clients & Transports](/docs/clients/intro): A brief introduction to Clients & Transports.
- [Public Client](/docs/clients/public): A function to create a Public Client
- [Wallet Client](/docs/clients/wallet): A function to create a Wallet Client.
- [Test Client](/docs/clients/test): A function to create a Test Client
- [Build your own Client](/docs/clients/custom)
- [HTTP Transport](/docs/clients/transports/http): A function to create a HTTP Transport for a Client
- [WebSocket Transport](/docs/clients/transports/websocket): A function to create a WebSocket Transport for a Client
- [Custom Transport](/docs/clients/transports/custom): A function to create a Custom Transport for a Client
- [IPC Transport](/docs/clients/transports/ipc): A function to create an IPC Transport for a Client
- [Fallback Transport](/docs/clients/transports/fallback): A function to create a Fallback Transport for a Client
- [Introduction to Public Actions](/docs/actions/public/introduction): A brief introduction on what Public Actions are in viem.
- [createAccessList](/docs/actions/public/createAccessList)
- [getBalance](/docs/actions/public/getBalance): Returns the balance of an address in wei.
- [getTransactionCount](/docs/actions/public/getTransactionCount): Returns the number of Transactions an Account has sent.
- [getBlock](/docs/actions/public/getBlock): Returns information about a block at a block number, hash or tag.
- [getBlockReceipts](/docs/actions/public/getBlockReceipts): Returns the transaction receipts of a block at a block number, hash or tag.
- [getBlockNumber](/docs/actions/public/getBlockNumber): Returns the number of the most recent block seen.
- [getBlockTransactionCount](/docs/actions/public/getBlockTransactionCount): Returns the number of Transactions at a block number, hash or tag.
- [simulateBlocks](/docs/actions/public/simulateBlocks): Simulates a set of calls on block(s).
- [watchBlockNumber](/docs/actions/public/watchBlockNumber): Watches and returns incoming block numbers.
- [watchBlocks](/docs/actions/public/watchBlocks): Watches and returns information for incoming blocks.
- [call](/docs/actions/public/call): An Action for executing a new message call.
- [simulateCalls](/docs/actions/public/simulateCalls): Simulates a set of calls on block(s).
- [getChainId](/docs/actions/public/getChainId): Returns the chain ID associated with the current network
- [getEip712Domain](/docs/actions/public/getEip712Domain): Reads the EIP-712 domain from a contract.
- [estimateFeesPerGas](/docs/actions/public/estimateFeesPerGas): Returns an estimate for the fees per gas (in wei) for a transaction to be likely included in the next block.
- [estimateGas](/docs/actions/public/estimateGas): An Action for estimating gas for a transaction.
- [estimateMaxPriorityFeePerGas](/docs/actions/public/estimateMaxPriorityFeePerGas): Returns an estimate for the max priority fee per gas (in wei) for a transaction to be likely included in the next block.
- [getBlobBaseFee](/docs/actions/public/getBlobBaseFee): Returns the current blob base fee (in wei).
- [getFeeHistory](/docs/actions/public/getFeeHistory): Returns a collection of historical gas information.
- [getGasPrice](/docs/actions/public/getGasPrice): Returns the current price of gas (in wei).
- [createBlockFilter](/docs/actions/public/createBlockFilter): An Action for creating a new Block Filter.
- [createEventFilter](/docs/actions/public/createEventFilter): An Action for creating a new Event Filter.
- [createPendingTransactionFilter](/docs/actions/public/createPendingTransactionFilter): An Action for creating a new pending transaction filter.
- [getFilterChanges](/docs/actions/public/getFilterChanges): Returns a list of logs or hashes based on a Filter.
- [getFilterLogs](/docs/actions/public/getFilterLogs): Returns a list of event logs since the filter was created.
- [getLogs](/docs/actions/public/getLogs): Returns a list of event logs matching the provided parameters.
- [watchEvent](/docs/actions/public/watchEvent): Watches and returns emitted Event Logs.
- [uninstallFilter](/docs/actions/public/uninstallFilter): Destroys a Filter.
- [getProof](/docs/actions/public/getProof): Returns the account and storage values of the specified account including the Merkle-proof.
- [verifyMessage](/docs/actions/public/verifyMessage): Verifies if a signed message was generated by the provided address.
- [verifyTypedData](/docs/actions/public/verifyTypedData): Verifies a typed data signature
- [prepareTransactionRequest](/docs/actions/wallet/prepareTransactionRequest): Prepares a transaction request for signing.
- [getTransaction](/docs/actions/public/getTransaction): Returns information about a transaction given a hash or block identifier.
- [getTransactionConfirmations](/docs/actions/public/getTransactionConfirmations): Returns the number of blocks passed (confirmations) since the transaction was processed on a block.
- [getTransactionReceipt](/docs/actions/public/getTransactionReceipt): Returns the transaction receipt given a transaction hash.
- [sendRawTransaction](/docs/actions/wallet/sendRawTransaction): Sends a signed transaction to the network
- [waitForTransactionReceipt](/docs/actions/public/waitForTransactionReceipt): Retrieves a Transaction Receipt for a given Transaction hash.
- [watchPendingTransactions](/docs/actions/public/watchPendingTransactions): Watches and returns pending transaction hashes.
- [Introduction to Wallet Actions](/docs/actions/wallet/introduction): A brief introduction to Wallet Actions in viem.
- [getAddresses](/docs/actions/wallet/getAddresses): Returns a list of addresses owned by the wallet or client.
- [requestAddresses](/docs/actions/wallet/requestAddresses): Requests a list of accounts managed by a wallet.
- [watchAsset](/docs/actions/wallet/watchAsset): Requests that the user tracks the token in their wallet.
- [getCallsStatus](/docs/actions/wallet/getCallsStatus): Returns the status of a call batch.
- [getCapabilities](/docs/actions/wallet/getCapabilities): Extract capabilities that a connected wallet supports.
- [sendCalls](/docs/actions/wallet/sendCalls): Sign and broadcast a batch of calls to the network.
- [sendCallsSync](/docs/actions/wallet/sendCallsSync): Sign and broadcast a batch of calls to the network, and waits for the calls to be included in a block.
- [showCallsStatus](/docs/actions/wallet/showCallsStatus): Requests for the wallet to show information about a call batch.
- [waitForCallsStatus](/docs/actions/wallet/waitForCallsStatus): Waits for a call batch to be confirmed & included on a Block.
- [addChain](/docs/actions/wallet/addChain): Adds an EVM chain to the wallet.
- [switchChain](/docs/actions/wallet/switchChain): Switch the target chain in a wallet.
- [signMessage](/docs/actions/wallet/signMessage): Signs a message with the Account's private key.
- [signTypedData](/docs/actions/wallet/signTypedData): Signs typed data with the Account's private key.
- [getPermissions](/docs/actions/wallet/getPermissions): Gets the wallets current permissions.
- [requestPermissions](/docs/actions/wallet/requestPermissions): Requests permissions for a wallet.
- [sendRawTransactionSync](/docs/actions/wallet/sendRawTransactionSync): Sends a signed transaction to the network synchronously
- [sendTransaction](/docs/actions/wallet/sendTransaction): Creates, signs, and sends a new transaction to the network.
- [sendTransactionSync](/docs/actions/wallet/sendTransactionSync): Creates, signs, and sends a new transaction to the network synchronously.
- [signTransaction](/docs/actions/wallet/signTransaction): Signs a transaction.
- [Introduction to Test Actions](/docs/actions/test/introduction): A brief introduction on what Test Actions are in viem.
- [impersonateAccount](/docs/actions/test/impersonateAccount): Impersonate an account or contract address.
- [setBalance](/docs/actions/test/setBalance): Modifies the balance of an account.
- [setCode](/docs/actions/test/setCode): Modifies the bytecode stored at an account's address.
- [setNonce](/docs/actions/test/setNonce): Modifies (overrides) the nonce of an account.
- [setStorageAt](/docs/actions/test/setStorageAt): Writes to a slot of an account's storage.
- [stopImpersonatingAccount](/docs/actions/test/stopImpersonatingAccount): Stop impersonating an account after having previously used impersonateAccount.
- [getAutomine](/docs/actions/test/getAutomine): Returns the automatic mining status of the node.
- [increaseTime](/docs/actions/test/increaseTime): Jump forward in time by the given amount of time, in seconds.
- [mine](/docs/actions/test/mine): Mine a specified number of blocks.
- [removeBlockTimestampInterval](/docs/actions/test/removeBlockTimestampInterval): Removes setBlockTimestampInterval if it exists.
- [setAutomine](/docs/actions/test/setAutomine): Enables or disables the automatic mining of new blocks with each new transaction submitted to the network.
- [setIntervalMining](/docs/actions/test/setIntervalMining): Sets the automatic mining interval (in seconds) of blocks.
- [setBlockTimestampInterval](/docs/actions/test/setBlockTimestampInterval): Sets the block's timestamp interval.
- [setBlockGasLimit](/docs/actions/test/setBlockGasLimit): Sets the block's gas limit.
- [setNextBlockBaseFeePerGas](/docs/actions/test/setNextBlockBaseFeePerGas): Sets the next block's base fee per gas.
- [setNextBlockTimestamp](/docs/actions/test/setNextBlockTimestamp): Sets the next block's timestamp.
- [setCoinbase](/docs/actions/test/setCoinbase): Sets the coinbase address to be used in new blocks.
- [setMinGasPrice](/docs/actions/test/setMinGasPrice): Change the minimum gas price accepted by the network (in wei).
- [reset](/docs/actions/test/reset): Resets the fork back to its original state.
- [setLoggingEnabled](/docs/actions/test/setLoggingEnabled): Enable or disable logging on the test node network.
- [setRpcUrl](/docs/actions/test/setRpcUrl): Sets the backend RPC URL.
- [dumpState](/docs/actions/test/dumpState): Serializes the current state into a savable data blob.
- [loadState](/docs/actions/test/loadState): Adds state previously dumped to the current chain.
- [revert](/docs/actions/test/revert): Revert the state of the blockchain at the current block.
- [snapshot](/docs/actions/test/snapshot): Snapshot the state of the blockchain at the current block.
- [dropTransaction](/docs/actions/test/dropTransaction): Removes a transaction from the mempool.
- [getTxpoolContent](/docs/actions/test/getTxpoolContent): Returns the details of all transactions currently pending for inclusion in the next block(s).
- [getTxpoolStatus](/docs/actions/test/getTxpoolStatus): Returns a summary of all the transactions currently pending for inclusion in the next block(s).
- [inspectTxpool](/docs/actions/test/inspectTxpool): Returns a summary of all the transactions currently pending for inclusion in the next block(s).
- [sendUnsignedTransaction](/docs/actions/test/sendUnsignedTransaction): Executes a transaction regardless of the signature.
- [JSON-RPC Account](/docs/accounts/jsonRpc): A function to create a JSON-RPC Account.
- [Local Accounts (Private Key, Mnemonic, etc)](/docs/accounts/local)
- [privateKeyToAccount](/docs/accounts/local/privateKeyToAccount): A function to create a Private Key Account.
- [mnemonicToAccount](/docs/accounts/local/mnemonicToAccount): A function to create a Mnemonic Account.
- [hdKeyToAccount](/docs/accounts/local/hdKeyToAccount): A function to create a Hierarchical Deterministic (HD) Account.
- [toAccount](/docs/accounts/local/toAccount): A function to create a Custom Account.
- [createNonceManager](/docs/accounts/local/createNonceManager): Creates a Nonce Manager for automatic nonce generation
- [signMessage (Local Account)](/docs/accounts/local/signMessage): Signs a message with the Account's private key.
- [signTransaction (Local Account)](/docs/accounts/local/signTransaction): Signs a transaction with the Account's private key.
- [signTypedData (Local Account)](/docs/accounts/local/signTypedData): Signs typed data with the Account's private key.
- [Chains](/docs/chains/introduction)
- [Fees](/docs/chains/fees): Configure chain-based fee data in Viem
- [Formatters](/docs/chains/formatters): Configure chain-based formatters in Viem
- [Serializers](/docs/chains/serializers): Configure chain-based serializers in Viem
- [Celo](/docs/chains/celo): Integrating with Celo in Viem
- [Getting Started with OP Stack](/op-stack): Getting started with the OP Stack in Viem
- [Getting Started with ZKsync](/zksync): Getting started with the ZKsync in Viem
- [Contract Instances](/docs/contract/getContract): A Contract Instance is a type-safe interface for performing contract-related actions with a specific ABI and address, created by the getContract function.
- [createContractEventFilter](/docs/contract/createContractEventFilter): Creates a Filter to retrieve contract event logs.
- [deployContract](/docs/contract/deployContract): Deploys a contract to the network, given bytecode & constructor arguments.
- [estimateContractGas](/docs/contract/estimateContractGas): Estimates the gas required to successfully execute a contract write function call.
- [getCode](/docs/contract/getCode): Retrieves the bytecode at an address.
- [getContractEvents](/docs/contract/getContractEvents): Returns a list of event logs matching the provided parameters.
- [getStorageAt](/docs/contract/getStorageAt): Returns the value from a storage slot at a given address.
- [multicall](/docs/contract/multicall): Batches up multiple functions on a contract in a single call.
- [readContract](/docs/contract/readContract): Calls a read-only function on a contract, and returns the response.
- [simulateContract](/docs/contract/simulateContract): Simulates & validates a contract interaction.
- [writeContract](/docs/contract/writeContract): Executes a write function on a contract.
- [writeContractSync](/docs/contract/writeContractSync): Executes a write function on a contract synchronously.
- [watchContractEvent](/docs/contract/watchContractEvent): Watches and returns emitted contract event logs.
- [decodeDeployData](/docs/contract/decodeDeployData): Decodes ABI encoded deploy data (bytecode & arguments).
- [decodeErrorResult](/docs/contract/decodeErrorResult): Decodes reverted error from a contract function call.
- [decodeEventLog](/docs/contract/decodeEventLog): Decodes ABI encoded event topics & data.
- [decodeFunctionData](/docs/contract/decodeFunctionData): Decodes ABI encoded data (4 byte selector & arguments) into a function name and arguments.
- [decodeFunctionResult](/docs/contract/decodeFunctionResult): Decodes the result of a function call on a contract.
- [encodeDeployData](/docs/contract/encodeDeployData): Encodes deploy data (bytecode & constructor args) into an ABI encoded value.
- [encodeErrorResult](/docs/contract/encodeErrorResult): Encodes a reverted error from a function call.
- [encodeEventTopics](/docs/contract/encodeEventTopics): Encodes an event (with optional arguments) into filter topics.
- [encodeFunctionData](/docs/contract/encodeFunctionData): Encodes the function name and parameters into an ABI encoded value (4 byte selector & arguments).
- [encodeFunctionResult](/docs/contract/encodeFunctionResult): Encodes structured return data into ABI encoded data.
- [parseEventLogs](/docs/contract/parseEventLogs): Extracts & decodes logs from a set of opaque logs.
- [getEnsAddress](/docs/ens/actions/getEnsAddress): Gets address for ENS name.
- [getEnsAvatar](/docs/ens/actions/getEnsAvatar): Gets the avatar of an ENS name.
- [getEnsName](/docs/ens/actions/getEnsName): Gets primary name for specified address.
- [getEnsResolver](/docs/ens/actions/getEnsResolver): Gets resolver for ENS name.
- [getEnsText](/docs/ens/actions/getEnsText): Gets a text record for specified ENS name.
- [labelhash](/docs/ens/utilities/labelhash): Hashes ENS label.
- [namehash](/docs/ens/utilities/namehash): Hashes ENS name.
- [normalize](/docs/ens/utilities/normalize): Normalizes ENS name to UTS46.
- [verifySiweMessage](/docs/siwe/actions/verifySiweMessage): Verifies EIP-4361 formatted message was signed.
- [createSiweMessage](/docs/siwe/utilities/createSiweMessage): Creates EIP-4361 formatted message.
- [generateSiweNonce](/docs/siwe/utilities/generateSiweNonce): Generates random EIP-4361 nonce.
- [parseSiweMessage](/docs/siwe/utilities/parseSiweMessage): Parses EIP-4361 formatted message into message fields object.
- [validateSiweMessage](/docs/siwe/utilities/validateSiweMessage): Validates EIP-4361 message.
- [decodeAbiParameters](/docs/abi/decodeAbiParameters): Decodes ABI encoded data.
- [encodeAbiParameters](/docs/abi/encodeAbiParameters): Generates ABI encoded data.
- [encodePacked](/docs/abi/encodePacked): Generates ABI encoded data.
- [getAbiItem](/docs/abi/getAbiItem): Retrieves an item from the ABI array.
- [parseAbi](/docs/abi/parseAbi): Parses human-readable ABI into JSON.
- [parseAbiItem](/docs/abi/parseAbiItem): Parses human-readable ABI item (e.g. error, event, function) into ABI item.
- [parseAbiParameter](/docs/abi/parseAbiParameter): Parses human-readable ABI parameter into ABI parameter.
- [parseAbiParameters](/docs/abi/parseAbiParameters): Parses human-readable ABI parameters into ABI parameters.
- [getDelegation](/docs/eip7702/getDelegation): Returns the address an account has delegated to via EIP-7702.
- [prepareAuthorization](/docs/eip7702/prepareAuthorization): Prepares an EIP-7702 Authorization for signing.
- [signAuthorization](/docs/eip7702/signAuthorization): Signs an EIP-7702 Authorization object.
- [hashAuthorization](/docs/eip7702/hashAuthorization): Calculates an Authorization object hash in EIP-7702 format.
- [recoverAuthorizationAddress](/docs/eip7702/recoverAuthorizationAddress): Recovers the original signing address from a signed Authorization object.
- [verifyAuthorization](/docs/eip7702/verifyAuthorization): Verifies that an Authorization object was signed by the provided address.
- [getAddress](/docs/utilities/getAddress): Converts an address into an address that is checksum encoded.
- [getContractAddress](/docs/utilities/getContractAddress): Retrieves a contract address.
- [isAddress](/docs/utilities/isAddress): Checks if the address is valid.
- [isAddressEqual](/docs/utilities/isAddressEqual): Checks if the given addresses (checksummed) are equal.
- [blobsToProofs](/docs/utilities/blobsToProofs): Compute the proofs for a list of blobs and their commitments.
- [blobsToCommitments](/docs/utilities/blobsToCommitments): Compute commitments from a list of blobs.
- [commitmentsToVersionedHashes](/docs/utilities/commitmentsToVersionedHashes): Transform a list of commitments to their versioned hashes.
- [commitmentToVersionedHash](/docs/utilities/commitmentToVersionedHash): Transform a commitment to it's versioned hash.
- [fromBlobs](/docs/utilities/fromBlobs): Transforms blobs into the originating data.
- [sidecarsToVersionedHashes](/docs/utilities/sidecarsToVersionedHashes): Transforms a list of sidecars to their versioned hashes.
- [toBlobs](/docs/utilities/toBlobs): Transforms arbitrary data into blobs.
- [toBlobSidecars](/docs/utilities/toBlobSidecars): Transforms arbitrary data into blob sidecars.
- [extractChain](/docs/utilities/extractChain)
- [concat](/docs/utilities/concat): Concatenates a set of hex values or byte arrays.
- [isBytes](/docs/utilities/isBytes): Checks whether the value is a byte array or not.
- [isHex](/docs/utilities/isHex): Checks whether the value is a hex value or not.
- [pad](/docs/utilities/pad): Pads a hex value or byte array with leading or trailing zeros.
- [slice](/docs/utilities/slice): Returns a section of the hex or byte array given a start/end bytes offset.
- [size](/docs/utilities/size): Retrieves the size of the value (in bytes).
- [trim](/docs/utilities/trim): Trims the leading or trailing zero byte data from a hex value or byte array.
- [fromBytes](/docs/utilities/fromBytes): Decodes a byte array to a string, hex value, boolean or number.
- [fromHex](/docs/utilities/fromHex): Decodes a hex value to a string, number or byte array.
- [fromRlp](/docs/utilities/fromRlp): Decodes a RLP value into a decoded hex value or byte array.
- [toBytes](/docs/utilities/toBytes): Encodes a string, hex value, number or boolean to a byte array.
- [toHex](/docs/utilities/toHex): Encodes a string, number, boolean or byte array to a hex value.
- [toRlp](/docs/utilities/toRlp): Encodes a hex value or byte array into a RLP encoded value.
- [isHash](/docs/utilities/isHash): Checks if a string is a valid 32-byte hex hash.
- [keccak256](/docs/utilities/keccak256): Calculates the Keccak256 hash of a byte array.
- [ripemd160](/docs/utilities/ripemd160): Calculates the Ripemd160 hash of a byte array.
- [sha256](/docs/utilities/sha256): Calculates the Sha256 hash of a byte array.
- [toEventHash](/docs/utilities/toEventHash): Returns the hash (of the event signature) for a given event definition.
- [toEventSelector](/docs/utilities/toEventSelector): Returns the event selector for a given event definition.
- [toEventSignature](/docs/utilities/toEventSignature): Returns the signature for a given event or event definition.
- [toFunctionHash](/docs/utilities/toFunctionHash): Returns the hash (of the function signature) for a given function definition.
- [toFunctionSelector](/docs/utilities/toFunctionSelector): Returns the function selector (4 byte encoding) for a given function definition.
- [toFunctionSignature](/docs/utilities/toFunctionSignature): Returns the signature for a given function definition.
- [setupKzg](/docs/utilities/setupKzg): Sets up and returns a KZG interface.
- [compactSignatureToSignature](/docs/utilities/compactSignatureToSignature): Parses a compact signature into signature format.
- [hashMessage](/docs/utilities/hashMessage): Hashes a message in EIP-191 format.
- [hashTypedData](/docs/utilities/hashTypedData): Hashes EIP-712 typed data.
- [isErc6492Signature](/docs/utilities/isErc6492Signature): Checks whether the signature is in ERC-6492 format.
- [parseCompactSignature](/docs/utilities/parseCompactSignature): Parses a hex formatted compact signature into a structured compact signature.
- [parseErc6492Signature](/docs/utilities/parseErc6492Signature): Parses a hex-formatted ERC-6492 flavoured signature.
- [parseSignature](/docs/utilities/parseSignature): Parses a hex formatted signature into a structured signature.
- [recoverAddress](/docs/utilities/recoverAddress): Recovers the signing address from a hash & signature.
- [recoverMessageAddress](/docs/utilities/recoverMessageAddress): Recovers the signing address from a message & signature.
- [recoverPublicKey](/docs/utilities/recoverPublicKey): Recovers the signing public key from a hash & signature.
- [recoverTransactionAddress](/docs/utilities/recoverTransactionAddress): Recovers the signing address from a transaction & signature.
- [recoverTypedDataAddress](/docs/utilities/recoverTypedDataAddress): Recovers the signing address from EIP-712 typed data & signature.
- [serializeCompactSignature](/docs/utilities/serializeCompactSignature): Serializes a compact signature into hex format.
- [serializeErc6492Signature](/docs/utilities/serializeErc6492Signature): Serializes a ERC-6492 flavoured signature into hex format.
- [serializeSignature](/docs/utilities/serializeSignature): Serializes a structured signature into hex format.
- [signatureToCompactSignature](/docs/utilities/signatureToCompactSignature): Parses a signature into a compact signature.
- [verifyMessage](/docs/utilities/verifyMessage): Verifies if a signed message was generated by the provided address.
- [verifyTypedData](/docs/utilities/verifyTypedData): Verifies a typed data signature
- [parseTransaction](/docs/utilities/parseTransaction): Converts a serialized transaction to a structured transaction.
- [serializeTransaction](/docs/utilities/serializeTransaction): Serializes a transaction object.
- [formatEther](/docs/utilities/formatEther): Converts numerical wei to a string representation of ether.
- [formatGwei](/docs/utilities/formatGwei): Converts numerical wei to a string representation of gwei.
- [formatUnits](/docs/utilities/formatUnits): Divides a number by a given exponent of base 10, and formats it into a string representation of the number.
- [parseEther](/docs/utilities/parseEther): Converts a string representation of ether to numerical wei.
- [parseGwei](/docs/utilities/parseGwei): Converts a string representation of gwei to numerical wei.
- [parseUnits](/docs/utilities/parseUnits): Multiplies a string representation of a number by a given exponent of base 10.
- [Terms](/docs/glossary/terms): Glossary of Terms in viem.
- [Types](/docs/glossary/types): Glossary of Types in viem.
- [Errors](/docs/glossary/errors): Glossary of Errors in viem.
- [Getting Started with Account Abstraction](/account-abstraction): Getting Started with Account Abstraction in Viem
- [Sending User Operations](/account-abstraction/guides/sending-user-operations)
- [Bundler Client](/account-abstraction/clients/bundler): A function to create a Bundler Client.
- [Paymaster Client](/account-abstraction/clients/paymaster): A function to create a Paymaster Client.
- [Smart Accounts](/account-abstraction/accounts/smart)
- [Coinbase Smart Wallet](/account-abstraction/accounts/smart/toCoinbaseSmartAccount)
- [MetaMask Smart Account](/account-abstraction/accounts/smart/toMetaMaskSmartAccount)
- [Thirdweb Smart Account](/account-abstraction/accounts/smart/toThirdwebSmartAccount)
- [Nexus Smart Account](/account-abstraction/accounts/smart/toNexusSmartAccount)
- [Light Smart Account](/account-abstraction/accounts/smart/toLightSmartAccount)
- [Kernel (ZeroDev) Smart Account](/account-abstraction/accounts/smart/toEcdsaKernelSmartAccount)
- [Safe Smart Account](/account-abstraction/accounts/smart/toSafeSmartAccount)
- [Simple Smart Account](/account-abstraction/accounts/smart/toSimpleSmartAccount)
- [Solady Smart Account](/account-abstraction/accounts/smart/toSoladySmartAccount)
- [Trust Smart Account](/account-abstraction/accounts/smart/toTrustSmartAccount)
- [toSmartAccount](/account-abstraction/accounts/smart/toSmartAccount): Creates a Smart Account with a provided Account Implementation.
- [signMessage (Smart Account)](/account-abstraction/accounts/smart/signMessage)
- [signTypedData (Smart Account)](/account-abstraction/accounts/smart/signTypedData)
- [signUserOperation (Smart Account)](/account-abstraction/accounts/smart/signUserOperation)
- [WebAuthn Account](/account-abstraction/accounts/webauthn)
- [toWebAuthnAccount](/account-abstraction/accounts/webauthn/toWebAuthnAccount)
- [createWebAuthnCredential](/account-abstraction/accounts/webauthn/createWebAuthnCredential)
- [estimateUserOperationGas](/account-abstraction/actions/bundler/estimateUserOperationGas): Estimates the gas values for a User Operation to be executed successfully.
- [getChainId](/account-abstraction/actions/bundler/getChainId): Returns the chain ID associated with the bundler
- [getSupportedEntryPoints](/account-abstraction/actions/bundler/getSupportedEntryPoints): Returns the EntryPoints that the bundler supports.
- [getUserOperation](/account-abstraction/actions/bundler/getUserOperation): Retrieves information about a User Operation given a hash.
- [getUserOperationReceipt](/account-abstraction/actions/bundler/getUserOperationReceipt): Returns the User Operation receipt given a User Operation hash.
- [prepareUserOperation](/account-abstraction/actions/bundler/prepareUserOperation): Prepares a User Operation for execution and fills in missing properties.
- [sendUserOperation](/account-abstraction/actions/bundler/sendUserOperation): Broadcasts a User Operation to the Bundler.
- [waitForUserOperationReceipt](/account-abstraction/actions/bundler/waitForUserOperationReceipt): Waits for the User Operation to be included on a Block, and then returns the User Operation receipt.
- [getPaymasterData](/account-abstraction/actions/paymaster/getPaymasterData): Retrieves paymaster-related properties to be used for the User Operation.
- [getPaymasterStubData](/account-abstraction/actions/paymaster/getPaymasterStubData): Retrieves paymaster-related properties to be used for the User Operation.
- [Getting Started](/experimental): Getting started with experimental features in Viem
- [Extending Client with ERC-7715](/experimental/erc7715/client): Setting up your Viem Client
- [grantPermissions](/experimental/erc7715/grantPermissions): Request permissions from a wallet to perform actions on behalf of a user.
- [Extending Client with ERC-7739 Actions](/experimental/erc7739/client): Setting up your Viem Client
- [signMessage](/experimental/erc7739/signMessage): Signs a personal sign message via Solady's ERC-1271 format.
- [signTypedData](/experimental/erc7739/signTypedData): Signs typed data via Solady's ERC-1271 format.
- [hashMessage](/experimental/erc7739/hashMessage): Hashes an EIP-191 message via ERC-7739 format.
- [hashTypedData](/experimental/erc7739/hashTypedData): Hashes EIP-712 typed data via Solady's ERC-1271 format.
- [wrapTypedDataSignature](/experimental/erc7739/wrapTypedDataSignature)
- [Extending Client with ERC-7811 Actions](/experimental/erc7811/client): Setting up your Viem Client
- [getAssets](/experimental/erc7811/getAssets): Requests to get assets for an account from a Wallet.
- [Extending Client with ERC-7821 Actions](/experimental/erc7821/client): Setting up your Viem Client
- [execute](/experimental/erc7821/execute): Executes call(s) using the `execute` function on an ERC-7821-compatible contract.
- [executeBatches](/experimental/erc7821/executeBatches): Executes batches of call(s) on an ERC-7821-compatible contract.
- [supportsExecutionMode](/experimental/erc7821/supportsExecutionMode): Checks if the contract supports the ERC-7821 execution mode.
- [Extending Client with ERC-7846 Actions](/experimental/erc7846/client): Setting up your Viem Client
- [connect](/experimental/erc7846/connect): Requests to connect Account(s).
- [disconnect](/experimental/erc7846/disconnect): Requests to disconnect account(s).
- [Extending Client with ERC-7895 Actions](/experimental/erc7895/client): Setting up your Viem Client
- [addSubAccount](/experimental/erc7895/addSubAccount): Requests to add a Sub Account.
- [Client](/op-stack/client): Setting up your Viem Client with the OP Stack
- [Chains](/op-stack/chains)
- [Deposits](/op-stack/guides/deposits)
- [Withdrawals](/op-stack/guides/withdrawals)
- [buildDepositTransaction](/op-stack/actions/buildDepositTransaction): Builds & prepares parameters for a deposit transaction to be initiated on an L1 and executed on the L2.
- [buildProveWithdrawal](/op-stack/actions/buildProveWithdrawal): Builds the transaction that proves a withdrawal was initiated on an L2.
- [estimateContractL1Fee](/op-stack/actions/estimateContractL1Fee): Estimates the L1 fee to execute an L2 contract write.
- [estimateContractL1Gas](/op-stack/actions/estimateContractL1Gas): Estimates the L1 gas to execute an L2 contract write.
- [estimateContractTotalFee](/op-stack/actions/estimateContractTotalFee): Estimates the total (L1 + L2) fee to execute an L2 contract write.
- [estimateContractTotalGas](/op-stack/actions/estimateContractTotalGas): Estimates the total (L1 + L2) gas to execute an L2 contract write.
- [estimateInitiateWithdrawalGas](/op-stack/actions/estimateInitiateWithdrawalGas): Estimates gas required to initiate a withdrawal on an L2 to the L1.
- [estimateL1Fee](/op-stack/actions/estimateL1Fee): Estimates the L1 fee to execute an L2 transaction.
- [estimateL1Gas](/op-stack/actions/estimateL1Gas): Estimates the amount of L1 gas required to execute an L2 transaction
- [estimateOperatorFee](/op-stack/actions/estimateOperatorFee): Estimates the operator fee to execute an L2 transaction.
- [estimateTotalFee](/op-stack/actions/estimateTotalFee): Estimates the L1 + L2 + operator fee to execute an L2 transaction.
- [estimateTotalGas](/op-stack/actions/estimateTotalGas): Estimates the amount of L1 + L2 gas required to execute an L2 transaction
- [initiateWithdrawal](/op-stack/actions/initiateWithdrawal): Initiates a withdrawal on an L2 to the L1.
- [buildInitiateWithdrawal](/op-stack/actions/buildInitiateWithdrawal): Builds & prepares parameters for a withdrawal to be initiated on an L2.
- [estimateDepositTransactionGas](/op-stack/actions/estimateDepositTransactionGas): Estimates gas to initiate a deposit transaction on an L1, which executes a transaction on an L2.
- [estimateFinalizeWithdrawalGas](/op-stack/actions/estimateFinalizeWithdrawalGas): Estimates gas required to finalize a withdrawal that occurred on an L2.
- [estimateProveWithdrawalGas](/op-stack/actions/estimateProveWithdrawalGas): Estimates gas required to prove a withdrawal that occurred on an L2.
- [getGame](/op-stack/actions/getGame): Retrieves a valid dispute game on an L2 that occurred after a provided L2 block number.
- [getGames](/op-stack/actions/getGames): Retrieves dispute games for an L2.
- [getL2Output](/op-stack/actions/getL2Output): Retrieves the first L2 output proposal that occurred after a provided block number.
- [getTimeToFinalize](/op-stack/actions/getTimeToFinalize): Returns the time until the withdrawal transaction can be finalized.
- [getTimeToNextGame](/op-stack/actions/getTimeToNextGame): Returns the time until the next L2 dispute game is submitted.
- [getTimeToNextL2Output](/op-stack/actions/getTimeToNextL2Output): Builds & prepares parameters for a withdrawal to be initiated on an L2.
- [getTimeToProve](/op-stack/actions/getTimeToProve): Gets time until the L2 withdrawal transaction is ready to be proved.
- [getWithdrawalStatus](/op-stack/actions/getWithdrawalStatus): Returns the current status of a withdrawal.
- [waitForNextGame](/op-stack/actions/waitForNextGame): Waits for the next dispute game to be submitted.
- [waitForNextL2Output](/op-stack/actions/waitForNextL2Output): Waits for the next L2 output (after the provided block number) to be submitted.
- [waitToFinalize](/op-stack/actions/waitToFinalize): Waits until the withdrawal transaction can be finalized.
- [waitToProve](/op-stack/actions/waitToProve): Waits until the L2 withdrawal transaction is ready to be proved.
- [depositTransaction](/op-stack/actions/depositTransaction): Initiates a deposit transaction on an L1, which executes a transaction on an L2.
- [finalizeWithdrawal](/op-stack/actions/finalizeWithdrawal): Finalizes a withdrawal that occurred on an L2.
- [proveWithdrawal](/op-stack/actions/proveWithdrawal): Proves a withdrawal that occurred on an L2.
- [extractTransactionDepositedLogs](/op-stack/utilities/extractTransactionDepositedLogs): Extracts "TransactionDeposited" logs from an opaque array of logs.
- [extractWithdrawalMessageLogs](/op-stack/utilities/extractWithdrawalMessageLogs): Extracts "MessagePassed" logs from a withdrawal initialization from an opaque array of logs.
- [getL2TransactionHash](/op-stack/utilities/getL2TransactionHash): Computes the L2 transaction hash from an L1 "TransactionDeposited" log.
- [getL2TransactionHashes](/op-stack/utilities/getL2TransactionHashes): Computes the L2 transaction hashes from an array of L1 "TransactionDeposited" logs.
- [getWithdrawals](/op-stack/utilities/getWithdrawals): Gets the messages from a withdrawal initialization.
- [getSourceHash](/op-stack/utilities/getSourceHash): Computes source hash of a deposit transaction.
- [opaqueDataToDepositData](/op-stack/utilities/opaqueDataToDepositData): Converts opaque data into a structured deposit data format.
- [getWithdrawalHashStorageSlot](/op-stack/utilities/getWithdrawalHashStorageSlot): Computes the withdrawal hash storage slot to be used when proving a withdrawal.
- [parseTransaction (OP Stack)](/op-stack/utilities/parseTransaction): Converts a serialized transaction to a structured transaction, with support for OP Stack.
- [serializeTransaction (OP Stack)](/op-stack/utilities/serializeTransaction): Serializes a transaction object, with support for OP Stack.
- [USDC (Circle)](/circle-usdc)
- [Integrating USDC into Your Application](/circle-usdc/guides/integrating)
- [Cross-Chain USDC Transfers](/circle-usdc/guides/cross-chain)
- [Cross Chain USDC Transfers with Bridge Kit](/circle-usdc/guides/bridge-kit)
- [Cross Chain USDC Transfers (CCTP Integration)](/circle-usdc/guides/manual-cctp)
- [Gasless USDC Transfers with Circle Paymaster](/circle-usdc/guides/paymaster)
- [Circle Smart Account](/circle-usdc/guides/smart-account)
- [Getting Started](/tempo/)
- [Chains](/tempo/chains)
- [Guides](/tempo/guides/): Task-oriented guides for building common Tempo features with Viem.
- [Create an Account](/tempo/guides/accounts/create): Create a Tempo Account from a private key, passkey, or device-bound key, and use it with a Viem client.
- [Sign In with a Passkey](/tempo/guides/accounts/passkeys): Create and restore WebAuthn passkey accounts for non-custodial browser sign-in on Tempo.
- [Use the Tempo Accounts SDK](/tempo/guides/accounts/accounts-sdk): Connect a Tempo account with the Tempo Accounts SDK and drive it with Viem and Tempo Actions.
- [Tempo Transactions](/tempo/transactions): Send your first Tempo Transaction with Viem, and discover the payment-native features they unlock.
- [Batch Calls](/tempo/guides/batch-calls): Bundle multiple operations into a single atomic Tempo Transaction.
- [Concurrent Transactions](/tempo/guides/concurrent-transactions): Send multiple Tempo Transactions in parallel using concurrent nonces.
- [Scheduled Transactions](/tempo/guides/scheduled-transactions): Sign a Tempo Transaction now and define when it can execute onchain.
- [Pay Fees in a Stablecoin](/tempo/guides/pay-fees): Pay Tempo transaction fees in any USD-denominated TIP-20 stablecoin.
- [Sponsor User Fees](/tempo/guides/sponsor-fees): Sponsor transaction fees on behalf of your users for a gasless experience on Tempo.
- [Create a TIP-20 Token](/tempo/guides/create-token): Deploy a TIP-20 stablecoin on Tempo and read its onchain metadata.
- [Mint & Burn Tokens](/tempo/guides/manage-token-balances): Mint and burn TIP-20 token supply on Tempo.
- [Transfer Tokens](/tempo/guides/transfer-tokens): Transfer TIP-20 tokens, authorize spenders, and read balances on Tempo.
- [Manage Token Roles & Supply](/tempo/guides/manage-token-roles): Grant and revoke TIP-20 roles, cap supply, and pause transfers on Tempo.
- [Configure Transfer Policies](/tempo/guides/transfer-policies): Restrict which accounts can send or receive a TIP-20 token with a transfer policy.
- [Distribute Token Rewards](/tempo/guides/token-rewards): Distribute rewards to TIP-20 holders and let them claim their share on Tempo.
- [Access Keys](/tempo/guides/access-keys/): Delegate signing to a secondary key with access keys, with spending limits, scopes, admin keys, and signature verification.
- [Authorize Access Keys](/tempo/guides/access-keys/authorize): Authorize an access key to sign transactions on behalf of an account, and defer authorization to a transaction.
- [Set Permissions & Limits](/tempo/guides/access-keys/permissions): Restrict an access key with an expiry, per-token spending limits, recurring limits, and call scopes.
- [Manage Access Keys](/tempo/guides/access-keys/manage): Update spending limits, revoke access keys, and inspect their onchain metadata and remaining limits.
- [Admin Access Keys](/tempo/guides/access-keys/admin): Authorize unrestricted admin access keys that can manage an account's other keys, and check admin status.
- [Witnesses](/tempo/guides/access-keys/witnesses): Bind a witness to a key authorization and burn it to revoke signed-but-not-yet-submitted authorizations.
- [Verify Signatures](/tempo/guides/access-keys/verify): Verify that a keychain signature was produced by an active access key for the expected account.
- [Stablecoin Exchange](/tempo/guides/stablecoin-exchange/): Trade stablecoins on Tempo's enshrined DEX, manage orders and balances, create trading pairs, and provide Fee AMM liquidity.
- [Swap Stablecoins](/tempo/guides/stablecoin-exchange/swap): Quote and swap one USD-denominated TIP-20 stablecoin for another on Tempo's enshrined DEX.
- [Place & Manage Orders](/tempo/guides/stablecoin-exchange/orders): Place limit and flip orders on Tempo's Stablecoin DEX, then read, inspect, and cancel them.
- [Manage Exchange Balances](/tempo/guides/stablecoin-exchange/balances): Read your internal Stablecoin DEX balances and withdraw them back to your Tempo wallet.
- [Create a Trading Pair](/tempo/guides/stablecoin-exchange/create-pair): Create a new trading pair on Tempo's Stablecoin DEX and configure a token's quote token.
- [Provide Fee AMM Liquidity](/tempo/guides/stablecoin-exchange/fee-amm-liquidity): Add and remove liquidity in Tempo's Fee AMM so stablecoin fee conversions can settle.
- [Virtual Addresses](/tempo/guides/virtual-addresses/): Register a master address and accept TIP-20 deposits at unlimited virtual addresses that forward to you without sweeps.
- [Register a Master Address](/tempo/guides/virtual-addresses/register): Mine a TIP-1022 proof-of-work salt and register a master address for virtual-address deposit forwarding.
- [Resolve & Accept Payments](/tempo/guides/virtual-addresses/resolve): Derive per-customer virtual deposit addresses offchain and resolve them to your master wallet.
- [Receive Policies](/tempo/guides/receive-policies/): Control who can pay you on Tempo with receive policies, validate inbound transfers, and recover blocked funds.
- [Set a Receive Policy](/tempo/guides/receive-policies/set): Set and read an account's receive policy to control which senders and tokens it accepts.
- [Validate Transfers](/tempo/guides/receive-policies/validate): Check whether a TIP-20 transfer would be accepted by a recipient's receive policy before sending it.
- [Handle Blocked Funds](/tempo/guides/receive-policies/blocked): Read, claim, and burn TIP-20 funds that a receive policy blocked from being credited.
- [Payment Channels](/tempo/guides/payment-channels/): Open funded TIP-20 channels on Tempo, stream off-chain vouchers, and settle or close to move funds onchain.
- [Open & Fund a Channel](/tempo/guides/payment-channels/open): Open and fund a TIP-20 payment channel on Tempo, top it up, and read its onchain state.
- [Send & Settle Vouchers](/tempo/guides/payment-channels/vouchers): Sign off-chain TIP-20 channel vouchers as the payer and settle them onchain as the payee.
- [Close & Withdraw](/tempo/guides/payment-channels/close): Close a TIP-20 payment channel from either side and withdraw the remaining deposit on Tempo.
- [Private Zones](/tempo/guides/zones/): Connect to private Tempo Zones, deposit funds into them, and withdraw back to Tempo Mainnet.
- [Connect to a Zone](/tempo/guides/zones/connect): Connect a Viem client to a private Tempo Zone and authenticate with an authorization token.
- [Deposit to a Zone](/tempo/guides/zones/deposit): Deposit TIP-20 stablecoins from Tempo Mainnet into a private Tempo Zone.
- [Withdraw from a Zone](/tempo/guides/zones/withdraw): Withdraw TIP-20 stablecoins from a private Tempo Zone back to Tempo Mainnet.
- [Accounts](/tempo/accounts/)
- [Account.fromSecp256k1](/tempo/accounts/account.fromSecp256k1)
- [Account.fromP256](/tempo/accounts/account.fromP256)
- [Account.fromWebAuthnP256](/tempo/accounts/account.fromWebAuthnP256)
- [Account.fromWebCryptoP256](/tempo/accounts/account.fromWebCryptoP256)
- [Overview](/tempo/actions/)
- [accessKey.authorize](/tempo/actions/accessKey.authorize)
- [accessKey.burnWitness](/tempo/actions/accessKey.burnWitness)
- [accessKey.getMetadata](/tempo/actions/accessKey.getMetadata)
- [accessKey.getRemainingLimit](/tempo/actions/accessKey.getRemainingLimit)
- [accessKey.isAdmin](/tempo/actions/accessKey.isAdmin)
- [accessKey.isWitnessBurned](/tempo/actions/accessKey.isWitnessBurned)
- [accessKey.revoke](/tempo/actions/accessKey.revoke)
- [accessKey.signAuthorization](/tempo/actions/accessKey.signAuthorization)
- [accessKey.updateLimit](/tempo/actions/accessKey.updateLimit)
- [accessKey.verifyHash](/tempo/actions/accessKey.verifyHash)
- [accessKey.watchAdminAuthorized](/tempo/actions/accessKey.watchAdminAuthorized)
- [accessKey.watchWitness](/tempo/actions/accessKey.watchWitness)
- [accessKey.watchWitnessBurned](/tempo/actions/accessKey.watchWitnessBurned)
- [amm.burn](/tempo/actions/amm.burn)
- [amm.getLiquidityBalance](/tempo/actions/amm.getLiquidityBalance)
- [amm.getPool](/tempo/actions/amm.getPool)
- [amm.mint](/tempo/actions/amm.mint)
- [amm.rebalanceSwap](/tempo/actions/amm.rebalanceSwap)
- [amm.watchBurn](/tempo/actions/amm.watchBurn)
- [amm.watchMint](/tempo/actions/amm.watchMint)
- [amm.watchRebalanceSwap](/tempo/actions/amm.watchRebalanceSwap)
- [channel.close](/tempo/actions/channel.close)
- [channel.getStates](/tempo/actions/channel.getStates)
- [channel.open](/tempo/actions/channel.open)
- [channel.requestClose](/tempo/actions/channel.requestClose)
- [channel.settle](/tempo/actions/channel.settle)
- [channel.signVoucher](/tempo/actions/channel.signVoucher)
- [channel.topUp](/tempo/actions/channel.topUp)
- [channel.withdraw](/tempo/actions/channel.withdraw)
- [fee.getUserToken](/tempo/actions/fee.getUserToken)
- [fee.setUserToken](/tempo/actions/fee.setUserToken)
- [fee.watchSetUserToken](/tempo/actions/fee.watchSetUserToken)
- [nonce.getNonce](/tempo/actions/nonce.getNonce)
- [nonce.watchNonceIncremented](/tempo/actions/nonce.watchNonceIncremented)
- [policy.create](/tempo/actions/policy.create)
- [policy.getData](/tempo/actions/policy.getData)
- [policy.isAuthorized](/tempo/actions/policy.isAuthorized)
- [policy.modifyBlacklist](/tempo/actions/policy.modifyBlacklist)
- [policy.modifyWhitelist](/tempo/actions/policy.modifyWhitelist)
- [policy.setAdmin](/tempo/actions/policy.setAdmin)
- [policy.watchAdminUpdated](/tempo/actions/policy.watchAdminUpdated)
- [policy.watchBlacklistUpdated](/tempo/actions/policy.watchBlacklistUpdated)
- [policy.watchCreate](/tempo/actions/policy.watchCreate)
- [policy.watchWhitelistUpdated](/tempo/actions/policy.watchWhitelistUpdated)
- [receivePolicy.burn](/tempo/actions/receivePolicy.burn)
- [receivePolicy.claim](/tempo/actions/receivePolicy.claim)
- [receivePolicy.get](/tempo/actions/receivePolicy.get)
- [receivePolicy.getBlockedBalance](/tempo/actions/receivePolicy.getBlockedBalance)
- [receivePolicy.set](/tempo/actions/receivePolicy.set)
- [receivePolicy.validate](/tempo/actions/receivePolicy.validate)
- [receivePolicy.watchBlocked](/tempo/actions/receivePolicy.watchBlocked)
- [receivePolicy.watchBurned](/tempo/actions/receivePolicy.watchBurned)
- [receivePolicy.watchClaimed](/tempo/actions/receivePolicy.watchClaimed)
- [receivePolicy.watchUpdated](/tempo/actions/receivePolicy.watchUpdated)
- [faucet.fund](/tempo/actions/faucet.fund)
- [reward.claim](/tempo/actions/reward.claim)
- [reward.distribute](/tempo/actions/reward.distribute)
- [reward.getGlobalRewardPerToken](/tempo/actions/reward.getGlobalRewardPerToken)
- [reward.getPendingRewards](/tempo/actions/reward.getPendingRewards)
- [reward.getUserRewardInfo](/tempo/actions/reward.getUserRewardInfo)
- [reward.setRecipient](/tempo/actions/reward.setRecipient)
- [reward.watchRewardDistributed](/tempo/actions/reward.watchRewardDistributed)
- [reward.watchRewardRecipientSet](/tempo/actions/reward.watchRewardRecipientSet)
- [simulate.simulateBlocks](/tempo/actions/simulate.simulateBlocks)
- [simulate.simulateCalls](/tempo/actions/simulate.simulateCalls)
- [dex.buy](/tempo/actions/dex.buy)
- [dex.cancel](/tempo/actions/dex.cancel)
- [dex.cancelStale](/tempo/actions/dex.cancelStale)
- [dex.createPair](/tempo/actions/dex.createPair)
- [dex.getBalance](/tempo/actions/dex.getBalance)
- [dex.getBuyQuote](/tempo/actions/dex.getBuyQuote)
- [dex.getOrder](/tempo/actions/dex.getOrder)
- [dex.getTickLevel](/tempo/actions/dex.getTickLevel)
- [dex.getSellQuote](/tempo/actions/dex.getSellQuote)
- [dex.place](/tempo/actions/dex.place)
- [dex.placeFlip](/tempo/actions/dex.placeFlip)
- [dex.sell](/tempo/actions/dex.sell)
- [dex.watchFlipOrderPlaced](/tempo/actions/dex.watchFlipOrderPlaced)
- [dex.watchOrderCancelled](/tempo/actions/dex.watchOrderCancelled)
- [dex.watchOrderFilled](/tempo/actions/dex.watchOrderFilled)
- [dex.watchOrderPlaced](/tempo/actions/dex.watchOrderPlaced)
- [dex.withdraw](/tempo/actions/dex.withdraw)
- [token.approve](/tempo/actions/token.approve)
- [token.burn](/tempo/actions/token.burn)
- [token.burnBlocked](/tempo/actions/token.burnBlocked)
- [token.changeTransferPolicy](/tempo/actions/token.changeTransferPolicy)
- [token.create](/tempo/actions/token.create)
- [token.getAllowance](/tempo/actions/token.getAllowance)
- [token.getBalance](/tempo/actions/token.getBalance)
- [token.getMetadata](/tempo/actions/token.getMetadata)
- [token.grantRoles](/tempo/actions/token.grantRoles)
- [token.hasRole](/tempo/actions/token.hasRole)
- [token.mint](/tempo/actions/token.mint)
- [token.pause](/tempo/actions/token.pause)
- [token.renounceRoles](/tempo/actions/token.renounceRoles)
- [token.revokeRoles](/tempo/actions/token.revokeRoles)
- [token.setRoleAdmin](/tempo/actions/token.setRoleAdmin)
- [token.setSupplyCap](/tempo/actions/token.setSupplyCap)
- [token.transfer](/tempo/actions/token.transfer)
- [token.unpause](/tempo/actions/token.unpause)
- [token.watchAdminRole](/tempo/actions/token.watchAdminRole)
- [token.watchApprove](/tempo/actions/token.watchApprove)
- [token.watchBurn](/tempo/actions/token.watchBurn)
- [token.watchCreate](/tempo/actions/token.watchCreate)
- [token.watchMint](/tempo/actions/token.watchMint)
- [token.watchRole](/tempo/actions/token.watchRole)
- [token.watchTransfer](/tempo/actions/token.watchTransfer)
- [validator.add](/tempo/actions/validator.add)
- [validator.changeOwner](/tempo/actions/validator.changeOwner)
- [validator.changeStatus](/tempo/actions/validator.changeStatus)
- [validator.get](/tempo/actions/validator.get)
- [validator.getByIndex](/tempo/actions/validator.getByIndex)
- [validator.getCount](/tempo/actions/validator.getCount)
- [validator.getNextFullDkgCeremony](/tempo/actions/validator.getNextFullDkgCeremony)
- [validator.getOwner](/tempo/actions/validator.getOwner)
- [validator.list](/tempo/actions/validator.list)
- [validator.setNextFullDkgCeremony](/tempo/actions/validator.setNextFullDkgCeremony)
- [validator.update](/tempo/actions/validator.update)
- [virtualAddress.getMasterAddress](/tempo/actions/virtualAddress.getMasterAddress)
- [virtualAddress.registerMaster](/tempo/actions/virtualAddress.registerMaster)
- [virtualAddress.resolve](/tempo/actions/virtualAddress.resolve)
- [wallet.deposit](/tempo/actions/wallet.deposit)
- [wallet.transfer](/tempo/actions/wallet.transfer)
- [wallet.swap](/tempo/actions/wallet.swap)
- [zone.deposit](/tempo/actions/zone.deposit)
- [zone.encryptedDeposit](/tempo/actions/zone.encryptedDeposit)
- [zone.getAuthorizationTokenInfo](/tempo/actions/zone.getAuthorizationTokenInfo)
- [zone.getDepositStatus](/tempo/actions/zone.getDepositStatus)
- [zone.getWithdrawalFee](/tempo/actions/zone.getWithdrawalFee)
- [zone.getZoneInfo](/tempo/actions/zone.getZoneInfo)
- [zone.requestVerifiableWithdrawal](/tempo/actions/zone.requestVerifiableWithdrawal)
- [zone.requestWithdrawal](/tempo/actions/zone.requestWithdrawal)
- [zone.signAuthorizationToken](/tempo/actions/zone.signAuthorizationToken)
- [withRelay](/tempo/transports/withRelay)
- [TempoAddress.format](/tempo/utilities/TempoAddress.format)
- [TempoAddress.parse](/tempo/utilities/TempoAddress.parse)
- [TempoAddress.validate](/tempo/utilities/TempoAddress.validate)
- [Storage.defaultStorage](/tempo/utilities/Storage.defaultStorage)
- [Storage.from](/tempo/utilities/Storage.from)
- [Storage.memory](/tempo/utilities/Storage.memory)
- [Storage.session](/tempo/utilities/Storage.session)
- [Client](/zksync/client): Setting up your ZKsync Viem Client
- [Chains](/zksync/chains)
- [toSinglesigSmartAccount (ZKsync)](/zksync/accounts/toSinglesigSmartAccount): Creates a single-signature ZKsync Smart Account
- [toMultisigSmartAccount (ZKsync)](/zksync/accounts/toMultisigSmartAccount): Creates a multi-signature ZKsync Smart Account
- [toSmartAccount (ZKsync)](/zksync/accounts/toSmartAccount): Creates a ZKsync Smart Account
- [deployContract](/zksync/actions/deployContract): Deploys a contract to the network, given bytecode & constructor arguments by using EIP712 transaction.
- [sendTransaction](/zksync/actions/sendTransaction): Creates, signs, and sends a new transaction to the network, with EIP712 transaction support.
- [signTransaction](/zksync/actions/signTransaction): Signs a transaction, with EIP712 transaction support.
- [writeContract](/zksync/actions/writeContract): Executes a write function on a contract, with EIP712 transaction support.
- [estimateGasL1ToL2](/zksync/actions/estimateGasL1ToL2): Returns an estimated gas for L1 to L2 execution.
- [getBlockDetails](/zksync/actions/getBlockDetails): Returns additional ZKsync-specific information about the L2 block.
- [getBridgehubContractAddress](/zksync/actions/getBridgehubContractAddress): Returns the Bridgehub smart contract address.
- [getDefaultBridgeAddresses](/zksync/actions/getDefaultBridgeAddress): Returns the addresses of the default ZKsync Era bridge contracts on both L1 and L2.
- [getGasPerPubData](/zksync/actions/getGasPerPubData): Returns the scaled gas per pubdata limit for the currently open batch.
- [getL1BatchDetails](/zksync/actions/getL1BatchDetails): Returns data pertaining to a given batch.
- [getL1BatchBlockRange](/zksync/actions/getL1BatchBlockRange): Returns the range of blocks contained within a batch given by batch number.
- [getL1BatchNumber](/zksync/actions/getL1BatchNumber): Returns the latest L1 batch number.
- [getL1TokenAddress](/zksync/actions/getL1TokenAddress): Returns the L1 token address equivalent for a L2 token address as they are not equal.
- [getL2TokenAddress](/zksync/actions/getL2TokenAddress): Returns the L2 token address equivalent for a L1 token address as they are not equal.
- [getLogProof](/zksync/actions/getLogProof): Given a transaction hash, and an index of the L2 to L1 log produced within the transaction, it returns the proof for the corresponding L2 to L1 log.
- [getTransactionDetails](/zksync/actions/getTransactionDetails): Returns data from a specific transaction given by the transaction hash.
- [estimateFee](/zksync/actions/estimateFee): Returns an estimated Fee for requested transaction.
- [getAllBalances](/zksync/actions/getAllBalances): Returns all known balances for a given account.
- [getBaseTokenL1Address](/zksync/actions/getBaseTokenL1Address): Returns the base token L1 address.
- [getL1ChainId](/zksync/actions/getL1ChainId): Returns the Chain Id of underlying L1 network.
- [getMainContractAddress](/zksync/actions/getMainContractAddress): Returns the address of a Main ZKsync Contract.
- [getRawBlockTransaction](/zksync/actions/getRawBlockTransactions): Returns data of transactions in a block.
- [getTestnetPaymasterAddress (depreated)](/zksync/actions/getTestnetPaymasterAddress): Returns the address of a Paymaster on a Testnet.
- [getL1Allowance](/zksync/actions/getL1Allowance): Determines the amount of approved tokens for a specific L1 bridge.
- [getL1Balance](/zksync/actions/getL1Balance): Returns the amount of the token held by the account on the L1 network.
- [getL1TokenBalance](/zksync/actions/getL1TokenBalance): Retrieve the token balance held by the contract on L1.
- [isWithdrawalFinalized](/zksync/actions/isWithdrawalFinalized): Returns whether the withdrawal transaction is finalized on the L1 network.
- [withdraw](/zksync/actions/withdraw): Initiates the withdrawal process which withdraws ETH or any ERC20 token from the associated account on L2 network to the target account on L1 network.
- [requestExecute](/zksync/actions/requestExecute): Requests execution of a L2 transaction from L1.
- [finalizeWithdrawal](/zksync/actions/finalizeWithdrawal): Proves the inclusion of the `L2->L1` withdrawal message.
- [deposit](/zksync/actions/deposit): Transfers the specified token from the associated account on the L1 network to the target account on the L2 network.
- [claimFailedDeposit](/zksync/actions/claimFailedDeposit): Withdraws funds from the initiated deposit, which failed when finalizing on L2.
- [getApprovalBasedPaymasterInput](/zksync/utilities/paymaster/getApprovalBasedPaymasterInput): Returns encoded formatted approval-based paymaster params.
- [getGeneralPaymasterInput](/zksync/utilities/paymaster/getGeneralPaymasterInput): Returns encoded formatted general-based paymaster params.
- [getL2HashFromPriorityOp](/zksync/utilities/bridge/getL2HashFromPriorityOp): Returns the hash of the L2 priority operation from a given L1 transaction receipt.
- [parseEip712Transaction](/zksync/utilities/parseEip712Transaction): Parse EIP712 transaction.
- [Viem · TypeScript Interface for Ethereum](/index)
- [Client](/experimental/client): Setting up your Viem Client
- [ZKsync](/docs/chains/zksync): Integrating with ZKsync in Viem
- [defineKzg](/docs/utilities/defineKzg): Defines a KZG interface.
- [fromBase58](/docs/utilities/fromBase58)
- [fromBase64](/docs/utilities/fromBase64)
- [toBase58](/docs/utilities/toBase58)
- [toBase64](/docs/utilities/toBase64)
- [opaqueDataToDepositData](/op-stack/utilities/fromOpaqueData): Decodes opaque deposit data found in the "TransactionDeposited" event log.
- [fee.validateToken](/tempo/actions/fee.validateToken)
- [Setup](/tempo/actions/setup)
- [withFeePayer](/tempo/transports/withFeePayer)
- [TODO](/account-abstraction/actions/bundler/introduction)
- [verifyHash](/docs/actions/public/verifyHash): Verifies if a signed hash was generated by the provided address.
-->

# simulateContract \[Simulates & validates a contract interaction.]

The `simulateContract` function **simulates**/**validates** a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.

This function does not require gas to execute and ***does not*** change the state of the blockchain. It is almost identical to [`readContract`](/docs/contract/readContract), but also supports contract write functions.

Internally, `simulateContract` uses a [Public Client](/docs/clients/public) to call the [`call` action](/docs/actions/public/call) with [ABI-encoded `data`](/docs/contract/encodeFunctionData).

## Usage

Below is a very basic example of how to simulate a write function on a contract (with no arguments).

The `mint` function accepts no arguments, and returns a token ID.

:::code-group

```ts [example.ts]
import { account, publicClient } from './config'
import { wagmiAbi } from './abi'

const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account,
})
```

```ts [abi.ts]
export const wagmiAbi = [
  ...
  {
    inputs: [],
    name: "mint",
    outputs: [{ name: "", type: "uint32" }],
    stateMutability: "view",
    type: "function",
  },
  ...
] as const;
```

```ts [config.ts]
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

// JSON-RPC Account
export const account = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
// Local Account
export const account = privateKeyToAccount(...)

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
```

:::

### Passing Arguments

If your function requires argument(s), you can pass them through with the `args` attribute.

TypeScript types for `args` will be inferred from the function name & ABI, to guard you from inserting the wrong values.

For example, the `mint` function name below requires a **tokenId** argument, and it is typed as `[number]`.

:::code-group

```ts [example.ts]
import { account, publicClient } from './config'
import { wagmiAbi } from './abi'

const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420], // [!code focus]
  account,
})
```

```ts [abi.ts]
export const wagmiAbi = [
  ...
  {
    inputs: [{ name: "owner", type: "uint32" }],
    name: "mint",
    outputs: [{ name: "", type: "uint32" }],
    stateMutability: "view",
    type: "function",
  },
  ...
] as const;
```

```ts [config.ts]
import { createPublicClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

// JSON-RPC Account
export const account = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
// Local Account
export const account = privateKeyToAccount(...)

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
```

:::

### Pairing with `writeContract`

The `simulateContract` function also pairs well with `writeContract`.

In the example below, we are **validating** if the contract write will be successful via `simulateContract`. If no errors are thrown, then we are all good. After that, we perform a contract write to execute the transaction.

:::code-group

```ts [example.ts]
import { account, walletClient, publicClient } from './config'
import { wagmiAbi } from './abi'

const { request } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account,
})
const hash = await walletClient.writeContract(request)
```

```ts [abi.ts]
export const wagmiAbi = [
  ...
  {
    inputs: [],
    name: "mint",
    outputs: [{ name: "", type: "uint32" }],
    stateMutability: "view",
    type: "function",
  },
  ...
] as const;
```

```ts [config.ts]
import { createPublicClient, custom, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

// JSON-RPC Account
export const account = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
// Local Account
export const account = privateKeyToAccount(...)

export const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum)
})

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
```

:::

### Handling Custom Errors

In the example below, we are **catching** a [custom error](https://blog.soliditylang.org/2021/04/21/custom-errors/) thrown by the `simulateContract`. It is important to include the custom error item in the contract `abi`.

You can access the custom error through the `data` attribute of the error:

:::code-group

```ts [example.ts] {13-27}
import { BaseError, ContractFunctionRevertedError } from 'viem';
import { account, walletClient, publicClient } from './config'
import { wagmiAbi } from './abi'

try {
  await publicClient.simulateContract({
    address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
    abi: wagmiAbi,
    functionName: 'mint',
    account,
  })
} catch (err) {
  if (err instanceof BaseError) {
    const revertError = err.walk(err => err instanceof ContractFunctionRevertedError)
    if (revertError instanceof ContractFunctionRevertedError) {
      const errorName = revertError.data?.errorName ?? ''
      // do something with `errorName`
    }
  }
}

```

```ts [abi.ts]
export const wagmiAbi = [
  ...
  {
    inputs: [],
    name: "mint",
    outputs: [{ name: "", type: "uint32" }],
    stateMutability: "view",
    type: "function",
  },
  // Custom solidity error
  {
    type: 'error',
    inputs: [],
    name: 'MintIsDisabled'
  },
  ...
] as const;
```

```solidity [WagmiExample.sol]
// ...
error MintIsDisabled();
contract WagmiExample {
  // ...

    function mint() public {
      // ...
      revert MintIsDisabled();
      // ...
    }

  // ...
}
```

```ts [config.ts]
import { createPublicClient, custom, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

// JSON-RPC Account
export const account = '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
// Local Account
export const account = privateKeyToAccount(...)

export const walletClient = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum)
})

export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
```

:::

### State Overrides

When using `simulateContract`, there sometimes needs to be an initial state change to make the transaction pass. A common use case would be an approval. For that, there are [state overrides](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call). In the example below, we are simulating sending a token on behalf of another user. To do this, we need to modify the state of the token contract to have maximum approve from the token owner.

:::code-group

```ts twoslash [example.ts]
// @twoslash-cache: {"v":2,"hash":"f66cdf0d4d6e9a06bcdadd6396d1d79dbdcf98a3ef6634bf4506b6719744ab07","data":"N4Igdg9gJgpgziAXAbVAFwJ4AcZJACwgDcYAnEAGhDRgA808AKAQwBsBLZuASgAIBjCGDhpezfoICuYNIl7AAOmF4qxUKKXhw5AQXWa4cANxLVvSGH4wAsszDMA5mQD8cgHJCrt+09K8APrzSsABm7GAwUCbKqnDsDmByjFjMpMwAtjA0pNrypmaq+Fz4cgASxdFmAL58ALwAfLwACqQQ6exwMAA8pXT1lbHxYDqSaISk7ABezGjsQkkpaZnZuSNjEBPTs0IASjAAjpLwaHWNLW0d3QDKQ2vjUzNzYHtokqRgACrYMP35KnEJaxaRwwJLAXiZQwg3hVOSKGIFCHApxyG4JZgAI1YNmRMAGKhqvAazVa7U6PT6+N4AM+aWE4m2iV4XU6EzYUzIvDoNDAUDgvCuZE4HEmMA+dLgDKeADEwF1xXZJfxGYK2SLMdjGrUBUL2aKFfTlTK5QalSrdeqsT8KLw0BKpUIufQYLz+U1UhksmQ4CyLRzSPVkAAGAC6ROaHuW3t9av9gdD9UYdsVDqZycNjJtECwjLgrjyCIKrOF/v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BhPcSZHCBWBjIRAIMHrAgjQygwQYCivBwsgJIkOxVchngEW6gSL2u9IZKuigmEcb2wEtKBKTkCDoeYw6RGTqyQ5Ysj2EpTGTJzNTcUFwDgYyNYnRlWjesU5fjl+0QCVpN0M0UYHIjqZHBQJOHbGb5FFygdYAeAS3qIHBBsMbwfxcbNaVtJ2k9YmJf6fECDIyyjSmCdBqNWVk+lVZ6ssAkGSiE2oxOQqcdo+2668AS0WXGgPyB1i0B3sszaTLeHgB5QWRAxC2WDwfaiBkiwpGyqQDgJkouOwqWlL8Jg6hxTZWI2wM7PA5CpdAtsqCPbMcJOyXZ9+TQO7K0TrsvO8RNVKyVS4JywejAKCAAD160tJcOAUNVTMB1UPs1TjqKQwJok0dARgDWhioRwChbUo0hKUbDahiy8EfdIrNXgVllSHJBkHWXXICJQK0bQwLPPln5Az6n5S+ipVIpgVgGcuQsE2QVxK4VcauDXFrh1x64DcMAI3Fsnwpm4lylua3LbntwRwAxDYNhnrBjxi5CwQFIMPARUDB58gPrPtuK0hy8BUByAREdCVjj4BZhDYcEMAtAV4lvBkCyWKgKs5fovZGlJIqhHuJaE3wygXQsqCAXMCQFYC+BWUklivz8FkOWBbAGIV3oS2VuOQMgHIWEK4FECkhbTGgUELKF4ChBVLD9n2sw5GHG0DAqIUsLXMScNgHawhB1zzZgqLVIIo4XCLuFdUcxEIuYWKKzAjYlRVQpEXrQ5FFChRawt4AaL5FqikhTUBbE9SrRjACUgUOMjLBmASAUAKljiBCA8A8iEAFUCqBAA="}
import { account, publicClient } from './config'
import { abi, address } from './contract'

// Allowance slot: A 32 bytes hex string representing the allowance slot of the sender.
const allowanceSlot = '0x....'

// Max allowance: A 32 bytes hex string representing the maximum allowance (2^256 - 1)
const maxAllowance = numberToHex(maxUint256)

const { result } = await publicClient.simulateContract({
  abi,
  address,
  account,
  functionName: 'transferFrom',
  args: [
    '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266', 
    account.address, 
    69420n
  ],
  stateOverride: [ // [!code hl]
    { // [!code hl]
      // modifying the state of the token contract // [!code hl]
      address, // [!code hl]
      stateDiff: [ // [!code hl]
        { // [!code hl]
          slot: allowanceSlot, // [!code hl]
          value: maxAllowance, // [!code hl]
        }, // [!code hl]
      ], // [!code hl]
    }, // [!code hl]
  ], // [!code hl]
})

console.log(result)
// @log: Output: true
```

```ts twoslash [contract.ts] filename="contract.ts"
// @twoslash-cache: {"v":2,"hash":"c9634683b04f0259f191442cfdd5642f9ade79db289f9239143e63bd2b75bb2f","data":"N4Igdg9gJgpgziAXAbVAFwJ4AcZJACwgDcYAnEAGhDRgA808BjCMONAAgEMopT45E7ADogADLQCCogEYAOAGwBORQEZG8gEwrZ0gMzzGKqCsUARACycNMRQFFpoxrf2j5MAELnZIyiDadSBkQVXSoAGxgwAHM0fCQAdio0AKiYIJBuXn5fMIBLMFxEUSpGfADORhpyYN0AXwp0bEKCYjJfGnomFjYuaVzBPm4WMIx2VCEwdin2Qahh0cwcQREAMwBXMErclhEAbgnpmZghsBH2ME4AWxhl6lJOVhWyADFSCEu9g+nZ+fZ/GgAsmtkn08phbpAwFhOBhONIIp9Jt9jnNTqN8lhgQIjiczuMkYcpj80ecrjdhH5IrBSIjCcjcQsmrdMnw4HBadN6uxgF86cSzhdrrc+IxclhcpE0By+SjfotySIWfxpewuTyCYT+aNBQqMpcIBspSB9hrDlr2PLbmt8mgNABWeQq2oAXRNZtlJINaExaGx5vxdKJHrOlop0ggEDCTtdExdvn8gSQsg04UiMTiiFC1BSaTwcNyOXyhRTIFK5UqbRq9UaODwhBI5CSdHSAAosG8cIEMABKC1MinrTZobZgHxUBNBRSyVPRWJIcxJHPpeWFgrzkple4V6rmavUJp11qN6jNvBtjtkTC9nW3ND3R4vN4fEDx5KJ4IaYogCKzjML7OkKk6Q6quhR2hu5ZVPOe4rogLQNu0p5weeECdlefzJICwL5mCGAQiw0KwvCMBjn4b5BCo5jyDO6ZICo4EAUBeD/DAQIgrkuGgUg1GlpuFRQYgu4NPutZwfWbRNp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4AjjTggWotQgA==="}
export const address = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'

export const abi = [
  {
    type: 'function',
    name: 'transferFrom',
    stateMutability: 'nonpayable',
    inputs: [
      {
        name: 'sender',
        type: 'address',
      },
      {
        name: 'recipient',
        type: 'address',
      },
      {
        name: 'amount',
        type: 'uint256',
      },
    ],
    outputs: [
      {
        type: 'bool',
      },
    ],
  },
] as const
```

```ts twoslash [config.ts] filename="config.ts"
// @twoslash-cache: {"v":2,"hash":"665fc004727466b0c417a0fa7eefb703b3c25b9fa74a5e8feb09a4d7026701a1","data":"N4Igdg9gJgpgziAXAbVAFwJ4AcZJACwgDcYAnEAGhDRgA808AKAQwBsBLZuASgAIAzAK5gAxmnYQwvEaRjMaABUEAjDiIDCHGGDQAeNKWZg4WCKTS86NMFDi8AKoeOnzFafmbspV7bd7qPL14AH15hWH4vGCheAF4wmxhIsGi3ZhERCGE0AHlSAEEoKFk4Ox8bO3yMrJ0Q3kLi+DtQ8KSomPjW5NTeUiwRAGURfBgAW2ZLel87ACV+oZHxuq72uISI9oA+RixmQ1GYGlI4RF4lVXYNLR11SUiAc30nEzM0N2HPMDTq7LyGkrgbj6g2GY2Ym24p3Oak07G0egMRherncnzcCj2cBgVUy2V06VxOj+RQBmyB81B402AB0wOxRi4LDI5IoVDDrgwqFAICIEIgQOpZPJ4LwJtDLv4ObwAO7sND4UW8e7sEhSZCOJGMgC6jHwaDQWBOAHojUQ4aMAHRwfBG7m8o0iDlwI1eAwQPiZMAPQSyGL8MyK5ABT46vUG42m81Wm1252OuE6OOBYzcC202kAWl4ABEeSdeGHDYgTWaxtHbXmHU6jVg2Zd02B8mc6yJJQmLOw7EZeK6yPx0jBeGgILxqSBaxcRGPeMgAFIDHIAOQzMwU6nqCgAkqH9UWTYcRrJBJazPcjdpbTASKwIDhjhX7cwsJ2jQArOCSDPAo18A7y6B2HAgjDKKdiyAYcJmmA9y8KoPIANa8GAx7KGQgJDs86TiJI6FClAXgwfwp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nWRSvWDXtjvCiz7WJQlSpTlQnWsujZ35H4/62tlQ3WjAkp5I1SOtxpLOHBXV2set3VeA+uyV0DoVaYMG1DxDOsr4qKMBpRqp4ZpTcDdS0gRvCxaZ1VxQvUI1vU6AfWzJfX9T+tvAjSQunJstTSIXSR/jMBICgDlAeaSB4A8ogDmTmRAA="}
import { createPublicClient, custom, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { mainnet } from 'viem/chains'

export const account = privateKeyToAccount('0x...')
 
export const publicClient = createPublicClient({
  chain: mainnet,
  transport: http()
})
```

:::

## Return Value

The simulation result and write request. Type is inferred.

## Parameters

### address

* **Type:** [`Address`](/docs/glossary/types#address)

The contract address.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', // [!code focus]
  abi: wagmiAbi,
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
})
```

### abi

* **Type:** [`Abi`](/docs/glossary/types#abi)

The contract's ABI.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi, // [!code focus]
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
})
```

### functionName

* **Type:** `string`

A function to extract from the ABI.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint', // [!code focus]
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
})
```

### account

* **Type:** `Account | Address | null`

The Account to simulate the contract method from.

Accepts a [JSON-RPC Account](/docs/clients/wallet#json-rpc-accounts) or [Local Account (Private Key, etc)](/docs/clients/wallet#local-accounts-private-key-mnemonic-etc). If set to `null`, it is assumed that the transport will handle the filling the sender of the transaction.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' // [!code focus]
})
```

### accessList (optional)

* **Type:** [`AccessList`](/docs/glossary/types#accesslist)

The access list.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  accessList: [{ // [!code focus:4]
    address: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',
    storageKeys: ['0x1'],
  }],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
})
```

### authorizationList (optional)

* **Type:** `AuthorizationList`

Signed EIP-7702 Authorization list.

```ts
const authorization = await walletClient.signAuthorization({ 
  contractAddress: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2', 
}) 

const { result } = await publicClient.simulateContract({
  address: account.address,
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  authorizationList: [authorization], // [!code focus]
})
```

:::note
**References**

* [EIP-7702 Overview](/docs/eip7702)
* [`signAuthorization` Docs](/docs/eip7702/signAuthorization)
  :::

### args (optional)

* **Type:** Inferred from ABI.

Arguments to pass to function call.

```ts
const { result } = await publicClient.simulateContract({
  address: '0x1dfe7ca09e99d10835bf73044a23b73fc20623df',
  abi: wagmiAbi,
  functionName: 'balanceOf',
  args: ['0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC'], // [!code focus]
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
})
```

### blockNumber (optional)

* **Type:** `number`

The block number to perform the read against.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  blockNumber: 15121123n, // [!code focus]
})
```

### blockTag (optional)

* **Type:** `'latest' | 'earliest' | 'pending' | 'safe' | 'finalized'`
* **Default:** `'latest'`

The block tag to perform the read against.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  blockTag: 'safe', // [!code focus]
})
```

### dataSuffix (optional)

* **Type:** `Hex`

Data to append to the end of the calldata. Useful for adding a ["domain" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f).

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  dataSuffix: '0xdeadbeef' // [!code focus]
})
```

### gas (optional)

* **Type:** `bigint`

The gas limit for the transaction.

```ts
await walletClient.writeContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  gas: 69420n, // [!code focus]
})
```

### gasPrice (optional)

* **Type:** `bigint`

The price (in wei) to pay per gas. Only applies to [Legacy Transactions](/docs/glossary/terms#legacy-transaction).

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  gasPrice: parseGwei('20'), // [!code focus]
})
```

### maxFeePerGas (optional)

* **Type:** `bigint`

Total fee per gas (in wei), inclusive of `maxPriorityFeePerGas`. Only applies to [EIP-1559 Transactions](/docs/glossary/terms#eip-1559-transaction)

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  maxFeePerGas: parseGwei('20'),  // [!code focus]
})
```

### maxPriorityFeePerGas (optional)

* **Type:** `bigint`

Max priority fee per gas (in wei). Only applies to [EIP-1559 Transactions](/docs/glossary/terms#eip-1559-transaction)

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  maxFeePerGas: parseGwei('20'),
  maxPriorityFeePerGas: parseGwei('2'), // [!code focus]
})
```

### nonce (optional)

* **Type:** `number`

Unique number identifying this transaction.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  nonce: 69 // [!code focus]
})
```

### stateOverride (optional)

* **Type:** [`StateOverride`](/docs/glossary/types#stateoverride)

The state override set is an optional address-to-state mapping, where each entry specifies some state to be ephemerally overridden prior to executing the call.

> Note: By using state overrides, you simulate the contract based on a fake state. Using this is useful for testing purposes, but making a transaction based on the returned `request` object might fail regardless of the simulation result.

```ts
const data = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  stateOverride: [ // [!code focus]
    { // [!code focus]
      address: '0xa5cc3c03994DB5b0d9A5eEdD10CabaB0813678AC', // [!code focus]
      balance: parseEther('1'), // [!code focus]
      stateDiff: [ // [!code focus]
        { // [!code focus]
          slot: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0', // [!code focus]
          value: '0x00000000000000000000000000000000000000000000000000000000000001a4', // [!code focus]
        }, // [!code focus]
      ], // [!code focus]
    } // [!code focus]
  ], // [!code focus]
})
```

### value (optional)

* **Type:** `number`

Value in wei sent with this transaction.

```ts
const { result } = await publicClient.simulateContract({
  address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',
  abi: wagmiAbi,
  functionName: 'mint',
  args: [69420],
  account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'
  value: parseEther('1') // [!code focus]
})
```

## Live Example

Check out the usage of `simulateContract` in the live [Writing to Contracts Example](https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts) below.

<iframe frameBorder="0" width="100%" height="500px" src="https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts?embed=1&file=index.ts&hideNavigation=1&hideDevTools=true&terminalHeight=0&ctl=1" />
