Lesson 5 of 5 Interacting with Contracts Using web3.js

Ethereum Client Libraries

web3.js was archived in March 2025, so a developer must know its status and its successors. This lesson explains the history of web3.js, compares it with ethers.js and viem, and maps common tasks between the libraries.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the status of web3.js.
  • Compare web3.js, ethers.js and viem.
  • Map common tasks between web3.js and ethers.js.

The status of web3.js

web3.js was the first Ethereum JavaScript library, created alongside the Ethereum Foundation's early tools and later maintained by ChainSafe. Version 1.x, used in most 2018-era material and in the original CBDE objectives, used callbacks and promises and returned numbers as strings. Version 4 (2023) was a TypeScript rewrite with BigInt values and a plugin system.

ChainSafe announced the end of the project and archived the web3.js repositories on 4 March 2025. The final 4.x packages remain on npm and work against current nodes, because JSON-RPC is stable, but they receive no further features or fixes. Existing applications can keep running; new projects normally choose ethers.js or viem.

True or false

web3.js today

Exam skills 1.1.3

Check the current status of web3.js and what it means for projects.

Log in to try this activity Interactive activities are free with an account.

Comparing the libraries

The following comparison sets out the three libraries.

web3.js 4
StatusArchived March 2025
Readingweb3.eth.*, contract.methods.f().call()
Writing.send({ from }), accounts wallet
NumbersBigInt
Used byOlder DApps and tutorials
ethers.js 6
StatusActively maintained
ReadingProvider; contract.f() for view functions
WritingSigner; contract.connect(signer).f()
NumbersBigInt
Used byHardhat mocha-ethers toolbox, many DApps
viem 2
StatusActively maintained
ReadingPublic client; readContract
WritingWallet client; writeContract
NumbersBigInt
Used byHardhat viem toolbox, wagmi-based front ends

The concepts are the same in all three: a connection to a node, a separate notion of who signs, contract objects built from an ABI, the difference between reading and sending, receipts and events.

Mapping common tasks

The following table shows the same tasks in web3.js and ethers.js.

Taskweb3.js 4ethers.js 6
Connectnew Web3(url)new ethers.JsonRpcProvider(url)
Balanceweb3.eth.getBalance(a)provider.getBalance(a)
Unitsweb3.utils.toWei("1", "ether")ethers.parseEther("1")
Contractnew web3.eth.Contract(abi, addr)new ethers.Contract(addr, abi, runner)
Readc.methods.x().call()await c.x()
Writec.methods.inc().send({ from })await (await c.inc()).wait()
Past eventsc.getPastEvents("E", opts)c.queryFilter(c.filters.E(), from, to)
Match the pairs

web3.js and ethers.js

Exam skills 1.1.3

Match each web3.js 4 call with its ethers.js 6 equivalent.

Log in to try this activity Interactive activities are free with an account.
Worked example

Maintaining an old DApp

A company runs a DApp built in 2019 with web3.js 1.x. A developer must add a feature. Must the DApp be rewritten immediately because web3.js is archived?

Not immediately. The archived library still works, because node JSON-RPC methods have not changed. The developer should plan a migration, upgrading at least to web3.js 4 or, better, to ethers.js or viem, because security fixes and support for new wallet and transaction features will no longer arrive. The risk grows over time rather than appearing overnight.

Worked example

Reading an ethers.js test

A Hardhat test contains const tx = await token.connect(alice).transfer(bob.address, 10n); await tx.wait();. What is the web3.js equivalent, and what does wait() do?

In web3.js: await token.methods.transfer(bob, 10n).send({ from: alice }). In ethers.js, calling a state-changing method returns a transaction response as soon as it is sent, and wait() waits until it is mined and returns the receipt; web3.js's send() promise resolves to the receipt directly.

Check yourself

When was web3.js archived, and which libraries do new projects usually choose instead?

Show answer

ChainSafe archived web3.js on 4 March 2025. New projects usually choose ethers.js or viem.

Exam Tips

Remember for the exam

  • ChainSafe archived web3.js on 4 March 2025; v4 still works but gets no updates.
  • ethers.js separates providers (read) from signers (write); viem uses public and wallet clients.
  • All three libraries use BigInt and wrap the same JSON-RPC methods.
  • Concepts (ABI, call versus send, receipts, events) transfer directly between libraries.