hicommonwealth / commonwealth

A platform for decentralized communities
https://commonwealth.im
GNU General Public License v3.0
66 stars 41 forks source link

Web3JS vs EthersJS vs Wagmi vs Viem (and Web3JS upgrading) #7338

Open timolegros opened 3 months ago

timolegros commented 3 months ago

Description

In the codebase we use both EthersJS and Web3JS. Both of these packages have essentially the same capabilities but both have their pros and cons. We should make a decision on which package we want to use and then use that accross the entire repo so we have a set standard (we can also consider Viem/Wagmi in the long-run).

If there are significant advantages to use one package over the other on the client we could consider using a different package on the client vs the server (e.g. lightweight web3 on client vs full EthersJS type-safety on the server). The main idea so to at least have a pattern of use so we don't use the same functionality from 2 different pacakges in adjacent files e.g. checkSum from Web3JS and checkSum from EthersJS.

If we settle on using Web3JS, we need to upgrade this package to v4. v1 is now considered legacy.

The estimated points for the ticket depends on which package we choose.

timolegros commented 3 months ago

Per the protocol office hours (4/4/2024), we would like to use Wagmi on the client side and Web3JS on the platform side. Timelines for transitioning have not been set but we don't expect to act on this decision for at least another month.

Reasoning:

Edit:

jxom commented 3 months ago

Happy to answer any Viem related questions if it's considered!

Web3JS is lighter than EthersJS/Viem in terms of coupling with types

How so? You don't have to lock yourself into strict types with Viem.

tmm commented 3 months ago

requires additional type generation/parsing

also worth noting that viem does not require type generation. all types are static at compile time.