# Viem > Build reliable Ethereum apps & libraries with lightweight, composable, & type-safe modules from viem. ## Docs - [Getting Started with Account Abstraction](/account-abstraction): **[Account Abstraction (ERC-4337)](https://eips.ethereum.org/EIPS/eip-4337)** is a proposal within the Ethereum ecosystem which aims to standardize Smart Contract Accounts (SCA) and their operations without the need to modify or upgrade the protocol. - [USDC (Circle)](/circle-usdc): This extension and guides are maintained by [Circle](https://www.circle.com). - [Getting Started](/experimental): Viem provides a set of experimental features through the `viem/experimental` entrypoint. Such features could include: - [Getting Started with OP Stack](/op-stack): Viem provides first-class support for chains implemented on the [OP Stack](https://docs.optimism.io/stack/getting-started). - [Getting Started with ZKsync](/zksync): **Note:** This extension is maintained by ZKsync collaborators. - [Chains](/zksync/chains): The following ZKsync chains are supported in Viem: - [Client](/zksync/client): To use the ZKsync functionality of Viem, you must extend your existing (or new) Viem Client with ZKsync Actions. - [parseEip712Transaction](/zksync/utilities/parseEip712Transaction): Parses a serialized EIP712 transaction. - [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. - [claimFailedDeposit](/zksync/actions/claimFailedDeposit): Withdraws funds from the initiated deposit, which failed when finalizing on L2. If the deposit L2 transaction has failed, it sends an L1 transaction calling `claimFailedDeposit` method of the L1 bridge, which results in returning L1 tokens back to the depositor. - [deployContract](/zksync/actions/deployContract): Deploys a contract to the network, given bytecode & constructor arguments by using EIP712 transaction. - [deposit](/zksync/actions/deposit): Transfers the specified token from the associated account on the L1 network to the target account on the L2 network. The token can be either ETH or any ERC20 token. For ERC20 tokens, enough approved tokens must be associated with the specified L1 bridge (default one or the one defined in `bridgeAddress`). In this case, depending on is the chain ETH-based or not `approveToken` or `approveBaseToken` can be enabled to perform token approval. If there are already enough approved tokens for the L1 bridge, token approval will be skipped. - [estimateFee](/zksync/actions/estimateFee): Returns an estimated Fee for requested transaction. - [estimateGasL1ToL2](/zksync/actions/estimateGasL1ToL2): Returns an estimated gas for L1 to L2 execution - [finalizeWithdrawal](/zksync/actions/finalizeWithdrawal): Proves the inclusion of the `L2->L1` withdrawal message. - [getAllBalances](/zksync/actions/getAllBalances): Returns all known balances for a given account. - [getBaseTokenL1Address](/zksync/actions/getBaseTokenL1Address): Returns the address of the ZKsync Chain's base L1 token. - [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. - [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. - [getL1BatchBlockRange](/zksync/actions/getL1BatchBlockRange): Returns the range of blocks contained within a batch given by batch number. - [getL1BatchDetails](/zksync/actions/getL1BatchDetails): Returns data pertaining to a given batch. - [getL1BatchNumber](/zksync/actions/getL1BatchNumber): Returns the latest L1 batch number. - [getL1ChainId](/zksync/actions/getL1ChainId): Returns the Chain Id of underlying L1 network. - [getL1TokenAddress](/zksync/actions/getL1TokenAddress): Returns the L1 token address equivalent for a L2 token address as they are not equal. - [getL1TokenBalance](/zksync/actions/getL1TokenBalance): Retrieve the token balance held by the contract on L1. - [getL2TokenAddress](/zksync/actions/getL2TokenAddress): Returns the L2 token address equivalent for a L1 token address as they are not equal. - [getLogProof](/zksync/actions/getLogProof): Returns the proof for the corresponding L2 to L1 log. - [getMainContractAddress](/zksync/actions/getMainContractAddress): Returns the address of a main ZKsync Chain Contract. - [getRawBlockTransaction](/zksync/actions/getRawBlockTransactions): Returns data of transactions in a block. - [getTestnetPaymasterAddress (depreated)](/zksync/actions/getTestnetPaymasterAddress): Returns the address of the testnet Paymaster. - [getTransactionDetails](/zksync/actions/getTransactionDetails): Returns data from a specific transaction given by the transaction hash. - [isWithdrawalFinalized](/zksync/actions/isWithdrawalFinalized): Returns whether the withdrawal transaction is finalized on the L1 network. - [requestExecute](/zksync/actions/requestExecute): Requests execution of a L2 transaction from L1. - [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. - [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. - [writeContract](/zksync/actions/writeContract): Executes a write function on a contract, with EIP712 transaction support. - [toMultisigSmartAccount (ZKsync)](/zksync/accounts/toMultisigSmartAccount): Creates a multi-signature [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts) from a Contract Address and the Private Key of the owner. - [toSinglesigSmartAccount (ZKsync)](/zksync/accounts/toSinglesigSmartAccount): Creates a single-signature [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts) from a Contract Address and the Private Key of the owner. - [toSmartAccount (ZKsync)](/zksync/accounts/toSmartAccount): Creates a [ZKsync Smart Account](https://docs.zksync.io/build/developer-reference/account-abstraction/building-smart-accounts) from a Contract Address and a custom sign function. - [Chains](/tempo/chains): The following Tempo chains are available: - [Getting Started](/tempo): [Tempo](https://tempo.xyz) is a purpose-built Layer 1 blockchain optimized for payments. - [Overview](/tempo/actions) - [Setup](/tempo/actions/setup): Setup the Tempo extension for Viem by following the steps below. - [Accounts](/tempo/accounts): Tempo.ts provides Viem-compatible [Local Accounts](https://viem.sh/docs/accounts/local) that support multiple signature schemes including **secp256k1**, **P256**, and **WebAuthn (passkeys)**. - [Chains](/op-stack/chains): The following Viem chains are implemented on the OP Stack: - [Client](/op-stack/client): Setting up your Viem Client with the OP Stack - [extractTransactionDepositedLogs](/op-stack/utilities/extractTransactionDepositedLogs): Extracts `TransactionDeposited` logs from an opaque array of logs. - [extractWithdrawalMessageLogs](/op-stack/utilities/extractWithdrawalMessageLogs): Extracts [`MessagePassed` logs](https://github.com/ethereum-optimism/optimism/blob/9f73402cb4341f7cfa83bf79769c8dddd9b014c0/packages/contracts-bedrock/src/L2/L2ToL1MessagePasser.sol#L29-L45) from a withdrawal initialization from an opaque array of logs. - [opaqueDataToDepositData](/op-stack/utilities/fromOpaqueData): Decodes opaque deposit data found in the `TransactionDeposited` event log data. - [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. - [getSourceHash](/op-stack/utilities/getSourceHash): Computes the [source hash](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md#source-hash-computation) of a deposit transaction. - [getWithdrawalHashStorageSlot](/op-stack/utilities/getWithdrawalHashStorageSlot): Computes the withdrawal hash storage slot to be used when proving a withdrawal. - [getWithdrawals](/op-stack/utilities/getWithdrawals): Gets withdrawal messages emitted from the [`MessagePassed` log](https://github.com/ethereum-optimism/optimism/blob/9f73402cb4341f7cfa83bf79769c8dddd9b014c0/packages/contracts-bedrock/src/L2/L2ToL1MessagePasser.sol#L29-L45) from a withdrawal initialization. - [opaqueDataToDepositData](/op-stack/utilities/opaqueDataToDepositData): Converts an opaque data into a structured deposit data object. This includes extracting and converting the `mint`, `value`, `gas`, `isCreation` flag, and `data` from a hex string. - [parseTransaction (OP Stack)](/op-stack/utilities/parseTransaction): Parses a serialized RLP-encoded transaction. Supports signed & unsigned Deposit, EIP-1559, EIP-2930 and Legacy Transactions. - [serializeTransaction (OP Stack)](/op-stack/utilities/serializeTransaction): Serializes a transaction object, with support for OP Stack transactions. Supports Deposit, EIP-1559, EIP-2930, and Legacy transactions. - [Deposits](/op-stack/guides/deposits): This guide will demonstrate how to deposit (bridge) **1 Ether** from **Mainnet** to **[Optimism (OP Mainnet)](https://www.optimism.io/)**. - [Withdrawals](/op-stack/guides/withdrawals): This guide will demonstrate how to withdraw **1 Ether** from **[Optimism (OP Mainnet)](https://www.optimism.io/)** to **Mainnet**. - [buildDepositTransaction](/op-stack/actions/buildDepositTransaction): Builds & prepares parameters for a [deposit transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md) to be initiated on an L1 and executed on the L2. - [buildInitiateWithdrawal](/op-stack/actions/buildInitiateWithdrawal): Builds & prepares parameters for a [withdrawal](https://community.optimism.io/docs/protocol/withdrawal-flow/#withdrawal-initiating-transaction) to be initiated on an L2. - [buildProveWithdrawal](/op-stack/actions/buildProveWithdrawal): Builds the transaction that proves a withdrawal was initiated on an L2. Used in the Withdrawal flow. - [depositTransaction](/op-stack/actions/depositTransaction): Initiates a [deposit transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md) on an L1, which executes a transaction on an L2. - [estimateContractL1Fee](/op-stack/actions/estimateContractL1Fee): Estimates the [L1 data fee](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) to execute an L2 contract write. - [estimateContractL1Gas](/op-stack/actions/estimateContractL1Gas): Estimates the [L1 data gas](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) to execute an L2 contract write. - [estimateContractTotalFee](/op-stack/actions/estimateContractTotalFee): Estimates the total ([L1 data](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) + L2) fee to execute an L2 contract write. - [estimateContractTotalGas](/op-stack/actions/estimateContractTotalGas): Estimates the total ([L1 data](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) + L2) gas to execute an L2 contract write. - [estimateDepositTransactionGas](/op-stack/actions/estimateDepositTransactionGas): Estimates gas to initiate a [deposit transaction](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md) 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. - [estimateInitiateWithdrawalGas](/op-stack/actions/estimateInitiateWithdrawalGas): Estimates gas required to initiate a [withdrawal](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md) on an L2 to the L1. - [estimateL1Fee](/op-stack/actions/estimateL1Fee): Estimates the [L1 data fee](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) to execute an L2 transaction. - [estimateL1Gas](/op-stack/actions/estimateL1Gas): Estimates the amount of [L1 data gas](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) required to execute an L2 transaction. - [estimateOperatorFee](/op-stack/actions/estimateOperatorFee): Estimates the [operator fee](https://docs.optimism.io/stack/transactions/fees#operator-fee) to execute an L2 transaction. - [estimateProveWithdrawalGas](/op-stack/actions/estimateProveWithdrawalGas): Estimates gas required to prove a withdrawal that occurred on an L2. - [estimateTotalFee](/op-stack/actions/estimateTotalFee): Estimates the [L1 data fee](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) + L2 fee + [operator fee](https://docs.optimism.io/stack/transactions/fees#operator-fee) to execute an L2 transaction. - [estimateTotalGas](/op-stack/actions/estimateTotalGas): Estimates the amount of [L1 data gas](https://docs.optimism.io/stack/transactions/fees#l1-data-fee) + L2 gas required to execute an L2 transaction. - [finalizeWithdrawal](/op-stack/actions/finalizeWithdrawal): Finalizes a withdrawal that occurred on an L2. Used in the Withdrawal flow. - [getGame](/op-stack/actions/getGame): Retrieves a valid dispute game on an L2 that occurred after a provided L2 block number. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getGames](/op-stack/actions/getGames): Retrieves dispute games for an L2. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getL2Output](/op-stack/actions/getL2Output): Retrieves the first L2 output proposal that occurred after a provided block number. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getTimeToFinalize](/op-stack/actions/getTimeToFinalize): Returns the time until the withdrawal transaction can be finalized. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getTimeToNextGame](/op-stack/actions/getTimeToNextGame): Returns the time until the next L2 dispute game (after the provided block number) is submitted. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getTimeToNextL2Output](/op-stack/actions/getTimeToNextL2Output): Returns the time until the next L2 output (after a provided block number) is submitted. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getTimeToProve](/op-stack/actions/getTimeToProve): Gets time until the L2 withdrawal transaction is ready to be proved. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [getWithdrawalStatus](/op-stack/actions/getWithdrawalStatus): Returns the current status of a withdrawal. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [initiateWithdrawal](/op-stack/actions/initiateWithdrawal): Initiates a [withdrawal](https://github.com/ethereum-optimism/optimism/blob/develop/specs/deposits.md) on an L2 to the L1. - [proveWithdrawal](/op-stack/actions/proveWithdrawal): Proves a withdrawal that occurred on an L2. Used in the Withdrawal flow. - [waitForNextGame](/op-stack/actions/waitForNextGame): Waits for the next dispute game (after the provided block number) to be submitted. Used within the [waitToProve](/op-stack/actions/waitToProve) Action. - [waitForNextL2Output](/op-stack/actions/waitForNextL2Output): Waits for the next L2 output (after the provided block number) to be submitted. Used within the [waitToProve](/op-stack/actions/waitToProve) Action. - [waitToFinalize](/op-stack/actions/waitToFinalize): Waits until the withdrawal transaction can be finalized. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [waitToProve](/op-stack/actions/waitToProve): Waits until the L2 withdrawal transaction is ready to be proved. Used for the [Withdrawal](/op-stack/guides/withdrawals) flow. - [Client](/experimental/client): Setting up your Viem Client - [addSubAccount](/experimental/erc7895/addSubAccount): Requests to add a Sub Account. [See more](https://github.com/ethereum/ERCs/blob/4d3d641ee3c84750baf461b8dd71d27c424417a9/ERCS/erc-7895.md) - [Extending Client with ERC-7895 Actions](/experimental/erc7895/client): Setting up your Viem Client - [Extending Client with ERC-7846 Actions](/experimental/erc7846/client): Setting up your Viem Client - [connect](/experimental/erc7846/connect): Requests to connect Account(s) with optional [capabilities](#capabilities). - [disconnect](/experimental/erc7846/disconnect): Requests to disconnect account(s). - [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](https://eips.ethereum.org/EIPS/eip-7821). - [executeBatches](/experimental/erc7821/executeBatches): Executes batches of call(s) using the ["batch of batches" mode](https://eips.ethereum.org/EIPS/eip-7821#optional-batch-of-batches-mode) on an [ERC-7821-compatible contract](https://eips.ethereum.org/EIPS/eip-7821). - [supportsExecutionMode](/experimental/erc7821/supportsExecutionMode): Checks if the contract supports the [ERC-7821](https://eips.ethereum.org/EIPS/eip-7821) execution mode. - [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-7739 Actions](/experimental/erc7739/client): Setting up your Viem Client - [hashMessage](/experimental/erc7739/hashMessage): Calculates a [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign hash via [ERC-7739 `PersonalSign` format](https://eips.ethereum.org/EIPS/eip-7739). - [hashTypedData](/experimental/erc7739/hashTypedData): Hashes [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via [ERC-7739 `TypedDataSign` format](https://eips.ethereum.org/EIPS/eip-7739). - [signMessage](/experimental/erc7739/signMessage): Signs an [EIP-191](https://eips.ethereum.org/EIPS/eip-191) personal sign message via [ERC-7739 `PersonalSign` format](https://eips.ethereum.org/EIPS/eip-7739). - [signTypedData](/experimental/erc7739/signTypedData): Signs [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data via [ERC-7739 `TypedDataSign` format](https://eips.ethereum.org/EIPS/eip-7739). - [wrapTypedDataSignature](/experimental/erc7739/wrapTypedDataSignature): Wraps a EIP-712 typed data signature into via [ERC-7739](https://eips.ethereum.org/EIPS/eip-7739) format for verification. - [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. - [Platform Compatibility](/docs/compatibility): Platforms compatible with Viem - [EIP-7702 Overview](/docs/eip7702): EIP-7702 is a proposal to add a new Transaction type to allow an EOA to designate a Smart Contract as its "implementation". - [Error Handling](/docs/error-handling): Every module in viem exports an accompanying error type which you can use to strongly type your `catch` statements. - [Ethers v5 → viem Migration Guide](/docs/ethers-migration): Migrate from Ethers v5 to viem - [Frequently Asked Questions](/docs/faq): Frequently asked questions related to viem. - [Getting Started](/docs/getting-started): Get started with viem in just a few lines of code. - [Installation](/docs/installation): Install Viem via your package manager, a `