@walletconnect/web3-provider vs @web3-react/core vs ethers vs web3-provider-engine
Web3 JavaScript Libraries
@walletconnect/web3-provider@web3-react/coreethersweb3-provider-engineSimilar Packages:

Web3 JavaScript Libraries

These libraries facilitate interaction with Ethereum and other blockchain networks, providing developers with tools to build decentralized applications (dApps). They enable functionalities such as wallet integration, state management, and communication with smart contracts, making it easier to create user-friendly blockchain applications. Each library has its unique strengths, catering to different aspects of web3 development, from wallet connectivity to state management and contract interactions.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
@walletconnect/web3-provider01,650876 kB75-Apache-2.0
@web3-react/core05,69167.6 kB1762 years agoGPL-3.0-or-later
ethers08,65313 MB6343 months agoMIT
web3-provider-engine06044.24 MB72 years agoMIT

Feature Comparison: @walletconnect/web3-provider vs @web3-react/core vs ethers vs web3-provider-engine

Wallet Integration

  • @walletconnect/web3-provider:

    This library provides a seamless way to connect various wallet providers, including mobile wallets, through the WalletConnect protocol. It allows users to interact with dApps using their preferred wallets without compromising security, as it does not require private keys to be exposed.

  • @web3-react/core:

    While primarily focused on state management, this library also facilitates wallet integration through hooks that manage connection states. It allows developers to easily connect to various wallet providers and handle user sessions effectively within React applications.

  • ethers:

    Ethers offers built-in support for wallet integration, allowing users to connect their wallets directly within the application. It provides utilities for managing wallet connections, signing transactions, and sending Ether, making it straightforward for developers to implement wallet functionality.

  • web3-provider-engine:

    This package is designed to support custom wallet integrations by allowing developers to create their own provider. It can manage multiple wallet connections and data sources, making it a flexible option for applications that require tailored wallet solutions.

Smart Contract Interaction

  • @walletconnect/web3-provider:

    This library does not directly handle smart contract interactions but facilitates wallet connections that can execute smart contract functions. It relies on other libraries like ethers or web3.js for contract interaction once connected.

  • @web3-react/core:

    It provides hooks that can be used in conjunction with other libraries to interact with smart contracts. While it manages connection states, developers will need to integrate it with libraries like ethers or web3.js for contract interactions.

  • ethers:

    Ethers excels in smart contract interactions, providing a simple and intuitive API for deploying and interacting with contracts. It allows developers to call contract methods, listen for events, and manage contract state efficiently, making it a go-to choice for Ethereum development.

  • web3-provider-engine:

    This library facilitates smart contract interactions by allowing developers to create a custom provider that can handle various blockchain data sources. It is particularly useful for applications that require complex interactions with multiple contracts or data feeds.

Learning Curve

  • @walletconnect/web3-provider:

    This library is relatively easy to learn, especially for developers familiar with wallet integration concepts. Its straightforward API allows for quick implementation of wallet connections, making it accessible for beginners in web3 development.

  • @web3-react/core:

    The learning curve is moderate, as it requires understanding React hooks and context. However, once familiar with these concepts, developers can efficiently manage wallet connections and blockchain state in their applications.

  • ethers:

    Ethers has a gentle learning curve, especially for those new to Ethereum development. Its clear documentation and intuitive API make it easy to get started with smart contracts and wallet management, appealing to both beginners and experienced developers.

  • web3-provider-engine:

    This library has a steeper learning curve due to its customizable nature. Developers need to understand how to create and manage providers effectively, which may require more in-depth knowledge of web3 concepts and architecture.

Extensibility

  • @walletconnect/web3-provider:

    This library is designed to be extensible, allowing developers to add support for additional wallet providers as needed. Its modular architecture makes it easy to integrate with various dApp frameworks and tools.

  • @web3-react/core:

    Highly extensible, this library allows developers to create custom hooks and components for managing wallet connections and state. It can be easily integrated with other libraries, providing flexibility in how developers structure their applications.

  • ethers:

    Ethers is extensible in terms of its functionality, allowing developers to create custom utilities and wrappers around its core features. However, it is primarily focused on Ethereum, which may limit its use in multi-chain applications without additional libraries.

  • web3-provider-engine:

    This package is built for extensibility, enabling developers to create custom providers that can handle various blockchain data sources. Its architecture supports plugins and extensions, making it suitable for complex applications that require tailored data handling.

Performance

  • @walletconnect/web3-provider:

    The performance is generally good, as it efficiently manages wallet connections without significant overhead. However, the actual performance may depend on the wallet provider being used and the network conditions.

  • @web3-react/core:

    Performance is optimized for React applications, as it minimizes unnecessary re-renders through its context API. This ensures that only components that need to update will do so, enhancing the overall performance of the application.

  • ethers:

    Ethers is known for its high performance, providing fast interactions with the Ethereum blockchain. Its lightweight design and efficient handling of transactions and contract calls contribute to a smooth user experience in dApps.

  • web3-provider-engine:

    Performance can vary based on the implementation of the custom provider. It allows for optimization based on specific application needs, but developers must ensure that their provider is efficient to avoid bottlenecks.

How to Choose: @walletconnect/web3-provider vs @web3-react/core vs ethers vs web3-provider-engine

  • @walletconnect/web3-provider:

    Choose this package if you need to integrate wallet connections in your dApp, particularly for mobile wallets. It supports multiple wallet providers and is essential for enabling users to interact with your application seamlessly through their wallets.

  • @web3-react/core:

    Opt for this package if you require a robust state management solution for your web3 application. It provides hooks and context for managing wallet connections and blockchain state efficiently, making it ideal for React applications that need to maintain connection states and user sessions.

  • ethers:

    Select ethers if you want a lightweight, user-friendly library for interacting with the Ethereum blockchain. It offers a comprehensive set of tools for managing wallets, signing transactions, and interacting with smart contracts, making it suitable for developers who prioritize simplicity and performance.

  • web3-provider-engine:

    Use this package if you need a customizable and extensible provider for web3 applications. It allows you to create your own provider that can handle multiple sources of blockchain data, making it a good choice for developers looking to build complex applications with specific data handling needs.

README for @walletconnect/web3-provider

WalletConnect Web3 Provider

Web3 Provider for WalletConnect

For more details, read the documentation

Setup

import Web3 from "web3";
import WalletConnectProvider from "@walletconnect/web3-provider";

//  Create WalletConnect Provider
const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1", // Required
});

//  Enable session (triggers QR Code modal)
await provider.enable();

//  Create Web3
const web3 = new Web3(provider);

Events (EIP-1193)

// Subscribe to accounts change
provider.on("accountsChanged", (accounts: string[]) => {
  console.log(accounts);
});

// Subscribe to chainId change
provider.on("chainChanged", (chainId: number) => {
  console.log(chainId);
});

// Subscribe to session connection
provider.on("connect", () => {
  console.log("connect");
});

// Subscribe to session disconnection
provider.on("disconnect", (code: number, reason: string) => {
  console.log(code, reason);
});

Provider Methods

interface RequestArguments {
  method: string;
  params?: unknown[] | object;
}

// Send JSON RPC requests
const result = await provider.request(payload: RequestArguments);

// Close provider session
await provider.disconnect()

Web3 Methods

//  Get Accounts
const accounts = await web3.eth.getAccounts();

//  Get Chain Id
const chainId = await web3.eth.chainId();

//  Get Network Id
const networkId = await web3.eth.net.getId();

// Send Transaction
const txHash = await web3.eth.sendTransaction(tx);

// Sign Transaction
const signedTx = await web3.eth.signTransaction(tx);

// Sign Message
const signedMessage = await web3.eth.sign(msg);

// Sign Typed Data
const signedTypedData = await web3.eth.signTypedData(msg);

Provider Options

Required

In order to resolve non-signing requests you need to provide one of the following:

Infura ID

The infuraId will support the following chainId's: Mainnet (1), Ropsten (3), Rinkeby(4), Goerli (5) and Kovan (42)

const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
});

RPC URL Mapping

The RPC URL mapping should indexed by chainId and it requires at least one value.

const provider = new WalletConnectProvider({
  rpc: {
    1: "https://mainnet.mycustomnode.com",
    3: "https://ropsten.mycustomnode.com",
    100: "https://dai.poa.network",
    // ...
  },
});

Optional

You can also customize the connector through the provider using the following options

Bridge URL

Use your own hosted bridge by providing the url

const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
  bridge: "https://bridge.myhostedserver.com",
});

Disable QR Code Modal

Use your own custom qrcode modal and disable the built-in one

const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
  qrcode: false,
});

provider.connector.on("display_uri", (err, payload) => {
  const uri = payload.params[0];
  CustomQRCodeModal.display(uri);
});

Filter Linking Options

If you would like to reduce the number of linking options or customize its order, you can provide an array of wallet names. Providing empty whitelist disables linking.

const provider = new WalletConnectProvider({
  infuraId: "27e484dcd9e3efcfd25a83a78777cdf1",
  qrcodeModalOptions: {
    mobileLinks: [
      "rainbow",
      "metamask",
      "argent",
      "trust",
      "imtoken",
      "pillar",
    ],
    desktopLinks: [
      "encrypted ink",
    ]
  }
});