https://docs.ethers.io/ethers.js/html/
What is ethers.js
The ethers.js library aims to be a complete and compact library for interacting with the Ethereum Blockchain and its ecosystem. It was originally designed for use with ethers.io and has since expanded into a much more general-purpose library.
ethers.js库旨在成为一个完整而紧凑的库,与Ethereum区块链及其生态系统进行交互。它最初是为与ethers.io一起使用而设计的,后来扩展成一个更通用的库。
Features
Keep your private keys in your client, safe and sound
私钥存储在客户端,更安全
Import and export JSON wallets (Geth, Parity and crowdsale)
导入、导出json钱包
Import and export BIP 39 mnemonic phrases (12 word backup phrases) and HD Wallets (English, Italian, Japanese, Korean, Simplified Chinese, Traditional Chinese; more coming soon)
导入、导出助记词和HD钱包
Meta-classes create JavaScript objects from any contract ABI, including ABIv2 and Human-Readable ABI
元类从任何合约ABI创建JavaScript对象,包括ABIv2和可读ABI
Connect to Ethereum nodes over JSON-RPC, INFURA, Etherscan, or MetaMask.
通过JSON-RPC,INFURA, Etherscan或MetaMask连接到Ethereum节点
ENS names are first-class citizens; they can be used anywhere an Ethereum addresses can be used ENS
域名是第一级公民,以太坊address能使用的任何地方它都可以使用
Tiny (~88kb compressed; 284kb uncompressed)更小
Complete functionality for all your Ethereum needs
有所有以太坊需要的函数
Extensive documentation 扩展文档
Large collection of test cases which are maintained and added to维护并添加测试用例
Fully TypeScript ready, with definition files and full TypeScript source
准备好完整的TypeScript,有着定义文件和完整的TypeScript源代码
MIT License (including ALL dependencies); completely open source to do with as you please
MIT许可(包括所有依赖项);完全开源
Developer Documentation
Getting Started
安装:
npm install --save ethers
导入:
1.JavaScript (ES5 or ES6)
const ethers = require('ethers');
2.JavaScript (ES6) / TypeScript
import { ethers } from 'ethers';
页面端使用:
<!-- This exposes the library as a global variable: ethers -->
<script src="https://cdn.ethers.io/scripts/ethers-v4.min.js"
charset="utf-8"
type="text/javascript">
</script>