Skip to main content

Web3 libraries

Web3 libraries provide access to helper methods that allow you to interact with the blockchain via a Web3 provider such as Infura (or your own node).

The Web3 libraries enable you to build frontends that can communicate with the blockchain (including smart contracts deployed on the blockchain).

Web3 libraries are available for various blockchains, for example, Matic.js for the Polygon network. This topic focuses on the Ethereum network, but the fundamentals are the same for other blockchains.

The following image shows how a Web3 library can connect to your node (in this example Infura) to communicate with the blockchain.

Some popular Ethereum compatible Web3 libraries include (but are not limited to) the following.

LanguageLibrary
JavaScriptWeb3.js, Ethers.js
PythonWeb3.py
Rustethers-js (recommended), Rust-web3
C++Aleth
PHPWeb3.php
JavaWeb3j
RubyEthereum Ruby library
How to access the blockchain

Refer to the Ethereum instructions for information on how to access the blockchain using some of these libraries.

Web3.js vs. Ethers.js

Web3.js and Ethers.js are two popular JavaScript Web3 libraries that enable frontend apps to interact with the Ethereum blockchain. They have similar functionality, with Web3.js currently being the most popular.

Refer to this Web3.js vs. Ethers.js article which highlights the differences between the libraries to help you decide which library to use.