ethers vs wagmi vs @walletconnect/client vs @web3modal/core vs @web3-react/core
Web3 and Blockchain Integration
etherswagmi@walletconnect/client@web3modal/core@web3-react/coreSimilar Packages:
Web3 and Blockchain Integration

Web3 and Blockchain Integration libraries provide tools and frameworks for building decentralized applications (dApps) that interact with blockchain networks. These libraries facilitate tasks such as connecting to wallets, sending transactions, reading and writing data on the blockchain, and managing user accounts. They are essential for developers looking to leverage blockchain technology in their applications, providing the necessary APIs and abstractions to work with smart contracts, cryptocurrencies, and decentralized protocols. These libraries help streamline the development process, enhance user experience, and ensure secure and efficient interactions with blockchain networks.

Npm Package Weekly Downloads Trend
3 Years
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
ethers2,628,8448,59813 MB61211 days agoMIT
wagmi424,3696,6121.2 MB1510 days agoMIT
@walletconnect/client106,0711,632188 kB77-Apache-2.0
@web3modal/core53,822-725 kB-a year agoApache-2.0
@web3-react/core32,7235,69867.6 kB1752 years agoGPL-3.0-or-later
Feature Comparison: ethers vs wagmi vs @walletconnect/client vs @web3modal/core vs @web3-react/core

Wallet Connection

  • ethers:

    ethers does not provide a built-in wallet connection solution but can be integrated with any wallet provider. It is compatible with wallets that support the Ethereum JSON-RPC API, allowing for flexible wallet interactions.

  • wagmi:

    wagmi provides hooks for connecting to wallets and managing wallet state. It supports multiple wallet providers and is designed to work seamlessly with React applications, making wallet connection easy and intuitive.

  • @walletconnect/client:

    @walletconnect/client provides a decentralized wallet connection protocol that allows users to connect their wallets using QR codes or deep links. It supports multiple wallets and is platform-agnostic, making it versatile for various applications.

  • @web3modal/core:

    @web3modal/core focuses on simplifying the wallet connection process by providing a modal interface for users to select their wallets. It supports multiple wallet providers and offers a seamless onboarding experience for users.

  • @web3-react/core:

    @web3-react/core offers a flexible wallet connection framework that allows developers to integrate multiple wallet providers easily. It provides hooks and context for managing wallet connections, making it highly customizable for React applications.

Smart Contract Interaction

  • ethers:

    ethers is a comprehensive library for interacting with smart contracts on the Ethereum blockchain. It provides a simple and intuitive API for reading and writing data to contracts, handling events, and managing transactions.

  • wagmi:

    wagmi simplifies smart contract interactions by providing hooks and utilities for reading and writing data to contracts. It integrates well with ethers.js, allowing for seamless contract interactions within React applications.

  • @walletconnect/client:

    @walletconnect/client does not handle smart contract interactions directly but facilitates transactions by connecting wallets that can sign and send transactions to the blockchain.

  • @web3modal/core:

    @web3modal/core focuses on wallet connection and does not provide direct support for smart contract interactions. However, it can be used alongside other libraries like ethers.js for contract interactions after the wallet is connected.

  • @web3-react/core:

    @web3-react/core does not provide built-in smart contract interaction features but allows developers to integrate any smart contract library (like ethers.js or web3.js) to interact with contracts once the wallet is connected.

User Experience

  • ethers:

    ethers focuses on providing a robust API for developers and does not directly address user experience. However, its simplicity and documentation make it easy for developers to create user-friendly interfaces for wallet and contract interactions.

  • wagmi:

    wagmi enhances user experience in React applications by providing hooks that simplify wallet connection and contract interactions. Its design encourages best practices and reduces boilerplate code, making it easier for developers to create intuitive interfaces.

  • @walletconnect/client:

    @walletconnect/client offers a user-friendly experience by allowing wallet connections via QR codes and deep links. However, the user interface is dependent on the wallet applications, which may vary.

  • @web3modal/core:

    @web3modal/core excels in user experience by providing a ready-to-use modal for wallet selection. It streamlines the connection process and supports multiple wallets, making it easy for users to connect.

  • @web3-react/core:

    @web3-react/core provides a good user experience but relies on developers to create their own UI components for wallet connection. It is highly customizable, allowing for tailored experiences.

Code Example

  • ethers:

    Smart Contract Interaction Example with ethers

    import { ethers } from 'ethers';
    
    const provider = new ethers.providers.Web3Provider(window.ethereum);
    const signer = provider.getSigner();
    const contract = new ethers.Contract(contractAddress, contractABI, signer);
    
    // Read from contract
    const value = await contract.getValue();
    console.log(`Value from contract: ${value}`);
    
    // Write to contract
    const tx = await contract.setValue(42);
    await tx.wait();
    console.log('Value updated in contract');
    
  • wagmi:

    Smart Contract Interaction Example with wagmi

    import { useContractRead, useContractWrite } from 'wagmi';
    import { ethers } from 'ethers';
    
    const contractAddress = '0xYourContractAddress';
    const contractABI = [/* Your Contract ABI */];
    
    function YourComponent() {
      const { data, isLoading } = useContractRead({
        address: contractAddress,
        abi: contractABI,
        functionName: 'getValue',
      });
    
      const { write } = useContractWrite({
        address: contractAddress,
        abi: contractABI,
        functionName: 'setValue',
      });
    
      return (
        <div>
          <h1>Value: {isLoading ? 'Loading...' : data}</h1>
          <button onClick={() => write()}>Update Value</button>
        </div>
      );
    }
    
  • @walletconnect/client:

    Wallet Connection Example with @walletconnect/client

    import { WalletConnectClient } from '@walletconnect/client';
    
    const connector = new WalletConnectClient({
      bridge: 'https://bridge.walletconnect.org', // Required
      qrcode: true,
    });
    
    // Create a new session
    connector.createSession().then(() => {
      // Get URI for QR Code
      const uri = connector.uri;
      console.log(`Connect with URI: ${uri}`);
    });
    
    // Subscribe to connection events
    connector.on('connect', (error, payload) => {
      if (error) throw error;
      const { account, chainId } = payload.params[0];
      console.log(`Connected: ${account}, Chain ID: ${chainId}`);
    });
    
    // Send a transaction
    const tx = {
      from: account,
      to: '0xRecipientAddress',
      value: '1000000000000000000', // 1 ETH
    };
    connector.sendTransaction(tx);
    
  • @web3modal/core:

    Wallet Connection Example with @web3modal/core

    import { Web3Modal } from '@web3modal/core';
    import { ethers } from 'ethers';
    
    const web3Modal = new Web3Modal({
      cacheProvider: true,
      providerOptions: {}, // Add your provider options here
    });
    
    async function connectWallet() {
      const provider = await web3Modal.connect();
      const web3Provider = new ethers.providers.Web3Provider(provider);
      const signer = web3Provider.getSigner();
      const address = await signer.getAddress();
      console.log(`Connected: ${address}`);
    }
    
  • @web3-react/core:

    Wallet Connection Example with @web3-react/core

    import { Web3ReactProvider } from '@web3-react/core';
    import { ethers } from 'ethers';
    
    function getLibrary(provider) {
      const library = new ethers.providers.Web3Provider(provider);
      library.pollingInterval = 12000; // Refresh every 12 seconds
      return library;
    }
    
    function App() {
      return (
        <Web3ReactProvider getLibrary={getLibrary}>
          <YourComponent />
        </Web3ReactProvider>
      );
    }
    
How to Choose: ethers vs wagmi vs @walletconnect/client vs @web3modal/core vs @web3-react/core
  • ethers:

    Use ethers if you require a comprehensive and lightweight library for interacting with the Ethereum blockchain. It provides tools for working with smart contracts, managing wallets, and handling transactions, making it suitable for both frontend and backend applications.

  • wagmi:

    Choose wagmi if you are building a React application and want a modern, hooks-based library for Ethereum. It simplifies the process of connecting to wallets, managing state, and interacting with smart contracts, while also providing excellent TypeScript support.

  • @walletconnect/client:

    Choose @walletconnect/client if you need a wallet connection solution that supports multiple wallets and platforms, including mobile and desktop. It is ideal for projects that require a decentralized and open-source protocol for connecting to wallets.

  • @web3modal/core:

    Opt for @web3modal/core if you need a complete solution for wallet onboarding and connection. It offers a customizable modal interface for users to select their wallets, making it easy to integrate multiple wallet providers in your dApp.

  • @web3-react/core:

    Select @web3-react/core if you want a flexible and customizable React library for managing wallet connections. It provides a set of hooks and components that allow you to integrate wallet connectivity into your React applications easily.

README for ethers

The Ethers Project

npm (tag) CI Tests npm bundle size (version) npm (downloads) GitPOAP Badge Twitter Follow


A complete, compact and simple library for Ethereum and ilk, written in TypeScript.

Features

  • Keep your private keys in your client, safe and sound
  • Import and export JSON wallets (Geth, Parity and crowdsale)
  • Import and export BIP 39 mnemonic phrases (12 word backup phrases) and HD Wallets (English as well as Czech, French, Italian, Japanese, Korean, Simplified Chinese, Spanish, Traditional Chinese)
  • Meta-classes create JavaScript objects from any contract ABI, including ABIv2 and Human-Readable ABI
  • Connect to Ethereum nodes over JSON-RPC, INFURA, Etherscan, Alchemy, Ankr or MetaMask
  • ENS names are first-class citizens; they can be used anywhere an Ethereum addresses can be used
  • Small (~144kb compressed; 460kb uncompressed)
  • Tree-shaking focused; include only what you need during bundling
  • Complete functionality for all your Ethereum desires
  • Extensive documentation
  • Large collection of test cases which are maintained and added to
  • Fully written in TypeScript, with strict types for security and safety
  • MIT License (including ALL dependencies); completely open source to do with as you please

Keep Updated

For advisories and important notices, follow @ethersproject on Twitter (low-traffic, non-marketing, important information only) as well as watch this GitHub project.

For more general news, discussions, and feedback, follow or DM me, @ricmoo on Twitter or on the Ethers Discord.

For the latest changes, see the CHANGELOG.

Summaries

Installing

NodeJS

/home/ricmoo/some_project> npm install ethers

Browser (ESM)

The bundled library is available in the ./dist/ folder in this repo.

<script type="module">
    import { ethers } from "./dist/ethers.min.js";
</script>

Documentation

Browse the documentation online:

Providers

Ethers works closely with an ever-growing list of third-party providers to ensure getting started is quick and easy, by providing default keys to each service.

These built-in keys mean you can use ethers.getDefaultProvider() and start developing right away.

However, the API keys provided to ethers are also shared and are intentionally throttled to encourage developers to eventually get their own keys, which unlock many other features, such as faster responses, more capacity, analytics and other features like archival data.

When you are ready to sign up and start using for your own keys, please check out the Provider API Keys in the documentation.

A special thanks to these services for providing community resources:

Extension Packages

The ethers package only includes the most common and most core functionality to interact with Ethereum. There are many other packages designed to further enhance the functionality and experience.

  • MulticallProvider - A Provider which bundles multiple call requests into a single call to reduce latency and backend request capacity
  • MulticoinPlugin - A Provider plugin to expand the support of ENS coin types
  • GanaceProvider - A Provider for in-memory node instances, for fast debugging, testing and simulating blockchain operations
  • Optimism Utilities - A collection of Optimism utilities
  • LedgerSigner - A Signer to interact directly with Ledger Hardware Wallets

License

MIT License (including all dependencies).