Jump to content

Draft:Web3.js

From Wikipedia, the free encyclopedia
Web3.js
Original author(s)Jeffrey Wilcke
Developer(s)ChainSafe Systems
Initial releaseSeptember 30, 2014; 10 years ago (2014-09-30)
Repositorygithub.com/web3/web3.js
Written inTypeScript
TypeJavaScript library
LicenseLGPL
Websiteweb3js.org

Web3.js is an open-source (released under the GNU Lesser General Public License[1]) 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),[2] querying blockchain nodes for network configuration or storage values,[3] creating and managing blockchain accounts,[4] smart contract interactions,[5] and more. Web3.js also exposes a platform for creating and using plugins,[6] which allows developers to extend its capabilities. Web3.js was initially released in 2014,[7] and is used by over 3,000 projects.[8]

Modular Design

[edit]

Web3.js is organized into a set of packages that each encapsulate a related set of capabilities.[9] 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

[edit]

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

[edit]

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

In late 2014, Merek Kotewicz of 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,[11] 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 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, ChainSafe Systems officially took over as the lead maintainer of the Web3.js library. In June of 2023,[12] ChainSafe released the first 4.x version of Web3.js, which was a complete rewrite in TypeScript.[13]

Features

[edit]

Ethereum JSON-RPC

[edit]

The Ethereum JSON-RPC is the primary mechanism for interacting with Ethereum networks.[14] Web3.js implements the Ethereum JSON-RPC specification, including subscriptions over WebSocket and IPC connections.[15]

Accounts

[edit]

Ethereum accounts are public/private key pairs.[16] Web3.js supports generating new key pairs and importing existing key pairs.[4] The Web3.js wallet supports the management of multiple key pairs.

Smart Contracts

[edit]

A smart contract is a piece of software that is executed in the context of a decentralized network, like Ethereum.[17] 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.[5]

Plugins

[edit]

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.[18] There are plugins for supporting the following capabilities and protocols:[19]

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

Alternatives

[edit]

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

References

[edit]
  1. ^ "Web3.js License". GitHub. June 10, 2015. Retrieved November 12, 2024.
  2. ^ "What are Web3.js Providers [Explained]". Metana. Retrieved November 13, 2024.
  3. ^ "Querying full and archive Ethereum nodes with JavaScript". Chainstack. Retrieved November 13, 2024.
  4. ^ a b "Technical Comparison: web3.js vs ethers.js". Tatum Blog. Retrieved November 13, 2024. Generating accounts and importing wallets using the web3.eth.accounts module.
  5. ^ a b "Intro to Web3.js · Ethereum Blockchain Developer Crash Course". Dapp University. Retrieved November 13, 2024.
  6. ^ "web3.js v4⚡️: Build your first web3 plugin 🧩". LearnWeb3. Retrieved November 13, 2024.
  7. ^ "Web3.js Vs Ethers.js – Which One is Better". MXICoders. Retrieved November 13, 2024. Web3.js was first introduced in 2014
  8. ^ "Websites using Web3.js". Built With. Retrieved November 12, 2024.
  9. ^ "Introduction, Packages & Plugins". Web3.js Docs. Retrieved November 12, 2024.
  10. ^ "Jeffrey Wilcke". IQ.wiki. Retrieved November 12, 2024.
  11. ^ "ERC-20: Token Standard". Ethereum Improvement Proposals. November 19, 2015. Retrieved November 12, 2024.
  12. ^ "Web3.js v4.0.1". GitHub. June 5, 2023. Retrieved November 12, 2024.
  13. ^ "Announcing the Full Release of Web3.js V4". ChainSafe Blog. ChainSafe Systems. June 7, 2023. Retrieved November 12, 2024.
  14. ^ "JSON-RPC API". ethereum.org. Retrieved November 12, 2024.
  15. ^ "Mastering Events Subscriptions". Web3.js Docs. Retrieved November 12, 2024.
  16. ^ "Ethereum Accounts, Externally-Owned Accounts and Key Pairs". ethereum.org. Retrieved November 12, 2024.
  17. ^ "Introduction to Smart Contracts". ethereum.org. Retrieved November 12, 2024.
  18. ^ "Plugin Developer Guide, Plugin Middleware". Web3.js Docs. Retrieved November 12, 2024.
  19. ^ "Plugins". web3js.org. Retrieved November 12, 2024.