Draft:Web3.js

{{AFC submission|d|v|u=68.8.5.250|ns=118|decliner=Pokelego999|declinets=20241219151829|reason2=nn|ts=20241113213234}}

{{AFC submission|d|nn|u=DanForbesChainSafe|ns=118|decliner=JJPMaster|declinets=20241113034034|small=yes|ts=20241112220437}}

{{AFC comment|1=No notability illustrated, with all sources being PRIMARY or unreliable. Please illustrate the subject's notability using secondary coverage from reliable sources. Magneton Considerer: Pokelego999 (Talk) (Contribs) 15:18, 19 December 2024 (UTC)}}

----

{{Short description|TypeScript library for interacting with Ethereum-compatible blockchain networks}}

{{Draft topics|internet-culture|software|computing|technology}}

{{AfC topic|stem}}

{{Primary sources|date=November 2024}}

{{infobox software|name=Web3.js|author=Jeffrey Wilcke|developer=[https://chainsafe.io/ ChainSafe Systems]|released={{start date and age|2014|9|30}}|repo={{URL|https://github.com/web3/web3.js}}|programming language=TypeScript|genre=JavaScript library|license=LGPL|website=[https://www.web3js.org/ web3js.org]}}

Web3.js is an open-source (released under the GNU Lesser General Public License{{cite web|url=https://github.com/web3/web3.js/blob/4.x/LICENSE|title=Web3.js License|website=GitHub|date=June 10, 2015|access-date=November 12, 2024}}) collection of JavaScript and TypeScript libraries for interacting with Ethereum-compatible blockchain networks. It supports connecting to blockchain nodes over HTTP, WebSocket, or IPC (inter-process communication),{{cite web|url=https://metana.io/blog/what-are-web3-js-providers-explained/|title=What are Web3.js Providers [Explained]|website=Metana|access-date=November 13, 2024}} querying blockchain nodes for network configuration or storage values,{{cite web|url=https://chainstack.com/querying-full-and-archive-evm-nodes-with-javascript/|title=Querying full and archive Ethereum nodes with JavaScript|website=Chainstack|date=24 August 2022 |access-date=November 13, 2024}} creating and managing blockchain accounts,{{cite web|url=https://tatum.io/blog/web3-js-vs-ethers-js|title=Technical Comparison: web3.js vs ethers.js|quote=Generating accounts and importing wallets using the web3.eth.accounts module.|website=Tatum Blog|access-date=November 13, 2024}} smart contract interactions,{{cite web|url=https://www.dappuniversity.com/articles/web3-js-intro|title=Intro to Web3.js · Ethereum Blockchain Developer Crash Course|website=Dapp University|date=14 February 2024 |access-date=November 13, 2024}} and more. Web3.js also exposes a platform for creating and using plugins,{{cite web|url=https://learnweb3.io/minis/web3-js-v4-build-your-first-web3-plugin/|title=web3.js v4⚡️: Build your first web3 plugin 🧩|website=LearnWeb3|access-date=November 13, 2024}} which allows developers to extend its capabilities. Web3.js was initially released in 2014,{{cite web|url=https://mxicoders.com/web3js-vs-ethersjs/|title=Web3.js Vs Ethers.js – Which One is Better|quote=Web3.js was first introduced in 2014|website=MXICoders|date=8 October 2024 |access-date=November 13, 2024}} and is used by over 3,000 projects.{{cite web|url=https://trends.builtwith.com/websitelist/Web3.js|title=Websites using Web3.js|website=Built With|access-date=November 12, 2024}}

Modular Design

Web3.js is organized into a set of packages that each encapsulate a related set of capabilities.{{cite web|url=https://docs.web3js.org/#packages--plugins|title=Introduction, Packages & Plugins|website=Web3.js Docs|access-date=November 12, 2024}} For instance, account creation and management capabilities are exposed by the web3-eth-accounts package, and the web3-eth-contract package exposes smart contract capabilities. This design is intended to give developers control over the final bundle size of their project.

= Packages =

Web3.js comprises the following packages:

  • web3 - umbrella package that includes all other packages
  • web3-core - common capabilities that are used across Web3.js packages
  • web3-errors - types and variables that relate to Web3.js errors
  • web3-eth - core features for interacting with Ethereum network
  • web3-eth-abi - functions for encoding and decoding ABIs (application binary interfaces)
  • web3-eth-accounts - functions for generating and using Ethereum accounts
  • web3-eth-contract - types and functions for working with smart contracts
  • web3-eth-ens - utilities for working with ENS (the Ethereum Name Service)
  • web3-eth-iban - supports converting between Ethereum and IBAN or BBAN addresses
  • web3-eth-personal - capabilities for interacting with Ethereum node accounts
  • web3-net - types and functions for working with the Ethereum network layer
  • web3-providers-http - supports connecting to an Ethereum node via HTTP
  • web3-providers-ipc - supports connecting to an Ethereum node via IPC (inter-process communication)
  • web3-providers-ws - supports connecting to an Ethereum node via WebSocket
  • web3-types - common types used by multiple Web3.js packages
  • web3-utils - helper functions for interacting with Ethereum networks
  • web3-validator - utilities for validating types and schemas

History

The initial Web3.js commit was made by Jeffrey Wilcke, co-founder of Ethereum, on September 30, 2014.{{cn}} At that time, Web3.js was an SDK for interacting with the Ethereum JSON-RPC.{{cn}}

In late 2014, Merek Kotewicz of [https://www.parity.io/ Parity Technologies] took over as lead maintainer of Web3.js, a position he held until 2017. In early 2015, Fabian Vogelsteller, the creator of the ERC-20 standard,{{cite web|url=https://eips.ethereum.org/EIPS/eip-20|title=ERC-20: Token Standard|website=Ethereum Improvement Proposals|date=November 19, 2015|access-date=November 12, 2024}} began contributing to Web3.js and took over as the lead maintainer from 2017 to 2018. During this time, Web3.js expanded its capabilities and was widely used by a huge influx of new Ethereum JavaScript developers.

In July 2018, Samuel Furter joined the [https://ethereum.foundation/ Ethereum Foundation] to take over as the lead maintainer of Web3.js. Samuel oversaw the release of Web3.js 1.x and ensured its stability throughout Ethereum's tremendous developer growth.

Ryan Ghods and Christopher Gewecke of EthereumJS took over the maintenance of Web3.js in 2019 and made contributions through version 1.2.x.

In June 2020, [https://chainsafe.io/ ChainSafe Systems] officially took over as the lead maintainer of the Web3.js library. In June of 2023,{{cite web|url=https://github.com/web3/web3.js/tree/v4.0.1|title=Web3.js v4.0.1|website=GitHub|date=June 5, 2023|access-date=November 12, 2024}} ChainSafe released the first 4.x version of Web3.js, which was a complete rewrite in TypeScript.{{cite web|url=https://blog.chainsafe.io/announcing-the-full-release-of-web3-js-v4/|title=Announcing the Full Release of Web3.js V4|website=ChainSafe Blog|publisher=ChainSafe Systems|date=June 7, 2023|access-date=November 12, 2024}}

Features

= Ethereum JSON-RPC =

The [https://ethereum.org/en/developers/docs/apis/json-rpc/ Ethereum JSON-RPC] is the primary mechanism for interacting with Ethereum networks.{{cite web|url=https://ethereum.org/en/developers/docs/apis/json-rpc/|title=JSON-RPC API|website=ethereum.org|access-date=November 12, 2024}} Web3.js implements the Ethereum JSON-RPC specification, including subscriptions over WebSocket and IPC connections.{{cite web|url=https://docs.web3js.org/guides/events_subscriptions/|title=Mastering Events Subscriptions|website=Web3.js Docs|access-date=November 12, 2024}}

= Accounts =

Ethereum accounts are public/private key pairs.{{cite web|url=https://ethereum.org/en/developers/docs/accounts/#externally-owned-accounts-and-key-pairs|title=Ethereum Accounts, Externally-Owned Accounts and Key Pairs|website=ethereum.org|access-date=November 12, 2024}} Web3.js supports generating new key pairs and importing existing key pairs. The Web3.js wallet supports the management of multiple key pairs.

= Smart Contracts =

A smart contract is a piece of software that is executed in the context of a decentralized network, like Ethereum.{{cite web|url=https://ethereum.org/en/developers/docs/smart-contracts/|title=Introduction to Smart Contracts|website=ethereum.org|access-date=November 12, 2024}} Web3.js provides capabilities for the JavaScript representation of smart contracts via their ABI (application binary interface). With Web3.js, developers can deploy smart contracts to Ethereum networks, as well as interact with previously deployed smart contracts by querying their state, submitting transactions, and subscribing to smart contract events.

= Plugins =

Since version 4.x, Web3.js has supported plugins, which allow developers to extend the capabilities of Web3.js. Web3.js plugins can be used to create helper or testing utilities, abstract smart contract interactions, or write middleware for the processing of transactions or RPC requests.{{cite web|url=https://docs.web3js.org/guides/web3_plugin_guide/plugin_authors#plugin-middleware|title=Plugin Developer Guide, Plugin Middleware|website=Web3.js Docs|access-date=November 12, 2024}} There are plugins for supporting the following capabilities and protocols:{{cite web|url=https://www.web3js.org/plugins|title=Plugins|website=web3js.org|access-date=November 12, 2024}}

  • 0x Swap
  • Blob transactions
  • Chainlink
  • Chainstack
  • Craftsman
  • ERC-721 non-fungible tokens
  • Near
  • OpenZeppelin
  • Smart contract multicalls
  • Starknet
  • Superfluid
  • Swisstronik
  • ZKsync

Alternatives

Other JavaScript SDKs for Ethereum networks include Ethers.js and Viem.

References

{{reflist}}