ethers.js vs viem in 2026: what changes when choosing or migrating
Versions, dependencies and a migration case: ethers throws on a reverted transaction, while viem returns the receipt without throwing.

When a user clicks «Confirm» in an Ethereum application, the code goes through several steps before showing a result: it builds the contract call from the ABI, asks the wallet for a signature, sends the transaction to an RPC node, waits for it to be included in a block and turns the receipt into a message. ethers.js and viem are the two TypeScript libraries used to write that flow, and each defines how every step is represented and what happens when one of them fails.
For a new TypeScript application, viem is today the option consistent with the rest of the ecosystem: wagmi 3 requires it as a dependency and Hardhat 3 offers a toolbox built on it. For an application that already works with ethers v6, the migration risk does not lie in rewriting calls, but in the fact that the two libraries react differently to the same events. Waiting for a receipt in ethers throws if the transaction reverts, while viem returns the receipt with a reverted status, so a line-by-line migration can report as completed an operation that failed on the network.
Which versions are current and who depends on each
ethers v6 was released in February 2023, and its latest version is 6.17.0, from 18 June 2026; v5 remains available on npm under the legacy-v5 tag (5.8.0). viem released version 2.0 in January 2024, and the 2.x line keeps receiving releases: six releases, from 2.57.12 to 2.57.17, appeared between 26 October and 8 November 2026. Version 3.0 is in preparation under the next npm tag (3.0.0-next.14, from October), so it is not yet a stable release for production.
Ecosystem dependencies tip the balance for new projects. wagmi 3.7, the React hooks library for connecting wallets, declares viem 2.x as a required peer dependency, and the viem-based Hardhat 3 toolbox requires viem 2.47.6 or later. A frontend using wagmi already loads viem; adding ethers for contract calls means maintaining two data models and two error hierarchies in the same bundle.
Provider and signer versus clients and actions
ethers organizes code around stateful objects: a Provider that talks to the node, a Signer that signs and a Contract that combines an ABI, an address and one of the former, so contract.withdraw(amount) builds, signs and sends in a single call. viem separates a public client, which reads, from a wallet client, which signs, and exposes every operation as an action with explicit parameters: readContract, simulateContract, writeContract or waitForTransactionReceipt. The resulting code is longer for simple calls and easier to follow when an operation combines simulation, signing and waiting, because each step returns a value that the next one receives.
Typing is the other design difference. viem infers function names, arguments and return types from the ABI when it is declared with as const or inline, through the ABIType library, and its TypeScript documentation requires TypeScript 5.0.4 or later. A misspelled function name or a wrongly typed argument shows up at compile time. Inference checks the code against the declared ABI, not against the deployed contract: if the address points to another version of the contract, the compiler cannot know, and that check belongs to tests against the network.
When a reverted transaction shows up as completed
Suppose, as a hypothetical example, an application that lets users withdraw funds from a deposit with a button. The ethers v6 version sends the transaction with contract.withdraw(amount), waits with await tx.wait() and shows «Withdrawal complete» if no exception is thrown; the catch block shows the error. That code covers the case in which the transaction is included in a block but reverts, because wait() checks the receipt and, if its status is 0, throws a CALL_EXCEPTION error with the message «transaction execution reverted».
The team migrates to viem and translates each line: writeContract sends the transaction and returns its hash, and waitForTransactionReceipt waits for the receipt. The try/catch structure stays, but the behavior changes. In viem 2.57.17, waitForTransactionReceipt resolves with the receipt without checking its status, and the receipt formatter maps the value 0x0 to status: 'reverted'; the promise only rejects on a timeout or an error querying the node. If another user withdraws between submission and inclusion and the deposit balance no longer covers the amount, the transaction is included, reverts, consumes gas, and the migrated interface shows «Withdrawal complete».
The fix is small once identified: check whether receipt.status is 'reverted' and treat it as an error, or wrap the wait in a function that reproduces the previous behavior. The hard part is finding it before production. A migration between libraries needs tests for every possible outcome of the flow (rejected signature, reverted transaction, transaction replaced from the wallet, unresponsive node), not only the happy path. viem also covers replacement: waitForTransactionReceipt detects whether the transaction was replaced by another with the same nonce and classifies the reason as cancelled, replaced or repriced, another outcome that needs its own message in the interface.
Simulating before sending does not reserve state
The writeContract documentation warns that the action does not validate whether the write will succeed and recommends calling simulateContract first, which executes the call without broadcasting it and returns the result or the revert reason; ethers offers the same check with staticCall on the contract method. Simulation lets the interface show an understandable error before asking for a signature, such as an insufficient balance, instead of a generic gas estimation failure in the wallet.
Simulation reflects the state of the queried block, not that of the block in which the transaction will be included. In the withdrawal case, the simulation passes and the transaction reverts later because the state changed between the two reads. Simulating and checking the receipt are two separate controls, one before signing and one after inclusion, and neither replaces the other.
Bundle size: what to measure before quoting a figure
A kilobyte figure without version, imports or bundler does not allow ethers and viem to be compared. viem is organized into independent actions that tree-shaking can drop when they are not imported, and the final result also depends on wallet connectors and bundler configuration. The figure that matters to a product is the JavaScript that reaches the browser on the page where users sign, measured with the same bundler and the same operations in both versions: connecting the wallet, reading a balance and sending a transaction.
ethers.js vs viem: the cost of migrating lies in error handling
viem solves two real problems well: it catches call errors against the declared ABI at compile time, and it makes each step of the flow explicit, which makes it easier to handle simulation, signing, inclusion and replacement separately. For a new frontend with React and wagmi, using another library for contracts adds a dependency without a clear benefit. ethers v6 is still maintained, with a release in June 2026, and an application that works with it does not become safer by migrating: it gains types and consistency with wagmi, at the cost of reviewing every place where the code relies on how ethers throws its errors.
If the migration goes ahead, order matters: first an inventory of the errors the interface consumes, then tests that trigger each one against a local network, and only then the replacement of calls. The arrival of viem 3 does not change this; while it remains under the next tag, a production project is written on the 2.x line.
Our team builds the frontend and smart contracts of decentralized applications, from an MVP to operation, and our guide on how to build a dApp covers the rest of the product decisions. If you are considering a migration, tell us which flows the application has and which errors it shows its users today.
- ethers.js v6.17.0 release (GitHub)
- ethers.js v6 source: TransactionResponse.wait (provider.ts)
- ethers.js v6 documentation
- viem 2.57.17 release (GitHub)
- viem source: waitForTransactionReceipt
- viem source: transaction receipt formatter
- viem: TypeScript
- viem: writeContract
- wagmi 3.7.11 on npm
- @nomicfoundation/hardhat-toolbox-viem 5.0.7 on npm
Frequently asked questions
Got a blockchain project in mind?
From idea to product, strategy and technology must move forward together.







