ethers.js vs viem: which one to use in your 2026 project
Compare ethers.js and viem interfaces, ABI-derived types and migration costs. Assess performance with the actual project and versions.

An application using Ethereum needs to read network data, communicate with contracts and request user signatures. viem and ethers.js are libraries that provide that connection from application code. Choosing between them affects how the team organizes calls, interprets responses and handles errors.
viem emphasizes type inference from the ABI, which describes the contract interface. ethers.js organizes work through providers, signers and contracts. Comparing both approaches on a project operation helps assess integrations and behavior when a user rejects a signature or a provider becomes unresponsive.
Types and Ethereum integration
viem can infer function names, arguments and return types from an ABI available as a literal type. This helps catch development errors, but does not verify that a deployed contract matches the ABI or prevent RPC failures, permission errors or state changes.
ethers.js v6 provides interfaces for contracts, providers and signers. A project built on its API should assess migration costs, third-party integrations and tests that need adapting. Switching libraries involves more than changing imports.
Comparing application size
There is no single package weight that describes every project. Results depend on versions, imports, bundlers and compression. Build two applications with the same operations: connect a wallet, read a contract and send a transaction. Measure JavaScript delivered to the browser, including connectors and dependencies.
Tree-shaking can remove unused code when the package and configuration support it. Publishing kB figures without this context conflates download size, complete package size and the final bundle.
An integration trial before choosing
- Check ABI inference and representations of integers and addresses.
- Test rejected signatures, account or network changes and transport errors.
- Distinguish transaction submission, inclusion and confirmation.
- Review SDK and wallet connector dependencies.
Use a transfer as the comparison workload
To evaluate both libraries, implement the same journey with a test token. The application reads the balance, converts the entered amount into contract units, prepares the operation and requests authorisation. It then retains the submission reference and checks the result. This proposed trial measures a complete integration without assuming performance differences in advance.
Include a decimal amount, insufficient balance and a network change during the process. If amount conversion loses precision, ABI typing does not automatically correct that business-logic error. Keep the value displayed to users separate from the integer passed to the contract.
viem provides simulateContract to simulate a call before submission. This can help detect rejection, but state may change before execution. Compare how the interface communicates that change and recovers the journey, as well as the code required for the call.
For a migration, retain reproducible cases for existing operations and compare results before replacing the library. Include the errors consumed by the frontend: a different exception representation can break the experience even when successful transactions still work.
Selection criteria
For a new TypeScript frontend, viem deserves a trial for its inference and modular API. With React, also examine wagmi integration. If ethers.js already meets product needs, require a concrete benefit before migrating.
These are technical evaluation criteria, not popularity rankings or security guarantees. Support the decision with a small prototype and the team's maintenance requirements.
Got a blockchain project in mind?
From idea to product, strategy and technology must move forward together.







