web3.js README

The project's README from github.com/web3/web3.js. As one markdown file: README.md.

web3.js

Web3.js

Web3.js libraries are being sunset on March 4th, 2025. For migration guides and more details please refer to Chainsafe blog

Dependency Status Unit Test Coverage Commit Activity Contributors

ES Version Node Version

Web3.js is a TypeScript implementation of the Ethereum JSON RPC API and related tooling maintained by ChainSafe Systems.

Installation

You can install the package either using NPM or using Yarn

If you wanna checkout latest bugfix or feature, use npm install web3@dev

Using NPM

npm install web3

Using Yarn

yarn add web3

Getting Started

Prerequisites

Migration Guide

Architecture Overview

Package Version License Docs Description
web3 npm License: LGPL v3 documentation :rotating_light: Entire Web3.js offering (includes all packages)
web3-core npm License: LGPL v3 documentation Core functions for web3.js packages
web3-errors npm License: LGPL v3 documentation Errors Objects
web3-eth npm License: LGPL v3 documentation Modules to interact with the Ethereum blockchain and smart contracts
web3-eth-abi npm License: LGPL v3 documentation Functions for encoding and decoding EVM in/output
web3-eth-accounts npm License: LGPL v3 documentation Functions for managing Ethereum accounts and signing
web3-eth-contract npm License: LGPL v3 documentation The contract package contained in web3-eth
web3-eth-ens npm License: LGPL v3 documentation Functions for interacting with the Ethereum Name Service
web3-eth-iban npm License: LGPL v3 documentation Functionality for converting Ethereum addressed to IBAN addressed and vice versa
web3-eth-personal npm License: LGPL v3 documentation Module to interact with the Ethereum blockchain accounts stored in the node
web3-net npm License: LGPL v3 documentation Functions to interact with an Ethereum node's network properties
web3-providers-http npm License: LGPL v3 documentation Web3.js provider for the HTTP protocol
web3-providers-ipc npm License: LGPL v3 documentation Web3.js provider for IPC
web3-providers-ws npm License: LGPL v3 documentation Web3.js provider for the Websocket protocol
web3-rpc-methods npm License: LGPL v3 documentation RPC Methods
web3-types npm License: LGPL v3 documentation Shared useable types
web3-utils npm License: LGPL v3 documentation Useful utility functions for Dapp developers
web3-validator npm License: LGPL v3 documentation Utilities for validating objects

Package.json Scripts

Script Description
clean Uses rimraf to remove dist/
build Uses tsc to build all packages
lint Uses eslint to lint all packages
lint:fix Uses eslint to check and fix any warnings
format Uses prettier to format the code
test Uses jest to run unit tests in each package
test:integration Uses jest to run tests under /test/integration in each package
test:unit Uses jest to run tests under /test/unit in each package
test:manual:long-connection-ws Runs manual tests for keeping a long WebSocket connection
test:manual Runs manual tests under test/manual in the web3 package

web3.js (web3/web3.js)

Searching Database…

19.9K ·GitHub
archived
这是干什么的?这是一套 TypeScript 库,用来通过 Ethereum 的 JSON RPC API 与以太坊区块链通信,还附带一些对 Dapp 开发者有用的工具函数。该项目由 ChainSafe Systems 维护。
它是一个大库,还是一组独立的包?它是一个包含大约 17 个包的 monorepo:顶层的 'web3' 包把所有功能打包在一起,而 web3-eth、web3-eth-contract、web3-utils 这类更专一的包可以单独使用。HTTP、IPC 和 WebSocket 连接提供方式也是独立的包。
怎么把它加到我的项目里?运行 'npm install web3' 或对应的 Yarn 命令;想获取最新的修复,可以用 'npm install web3@dev'。
使用之前我需要先装什么?需要 Node.js——代码面向 Node >= 14,README 建议使用 LTS 版本,比如 Fermium。Yarn 和 Lerna 也被列为前置要求,但只有在你自己构建这个 monorepo 时才用得上。
Web3.js 还在积极开发吗?没有了——这些库将于 2025 年 3 月 4 日停止维护,GitHub 仓库也已归档,所以不会再有更新。ChainSafe 的博客上有相关公告和迁移指南。
我以前跟着旧教程学的是 1.x 版的 API,那些代码还能用吗?不能直接用了:4.x 版本引入了破坏性变更,仓库里附带了一份迁移指南,建议先从它入手逐一了解这些变更。有问题的话,README 指向的是项目的 Discord。
除了发送交易,我还能用它做什么?这些包覆盖了 Dapp 开发的方方面面:对 EVM 输入输出进行 ABI 编码和解码、账户管理和签名、智能合约交互、Ethereum Name Service 域名查询、以太坊地址与 IBAN 之间的转换,另外还有各种校验和工具辅助函数。
我的应用怎么通过它连接以太坊节点?通过可插拔的 provider,它们以独立包的形式提供:HTTP、IPC 和 WebSocket。仓库里甚至还有一个手动测试套件,专门用来保持 WebSocket 长连接不断开。
我能在 React 这类浏览器应用里用它吗?可以——README 链接了一个 React App Example 和一份 tree-shaking 指南,让你只打包实际导入的部分,而且构建流程会生成专门的网页版本。
Creator
web3
Size
133.9 MB
Stars
19.9K
Age
12y
Commits · 90 Days