@0xcert/ethereum-scanner 中文文档教程
0xcert 以太坊区块链解析器。
这是一个用 TypeScript 编写的 NodeJS 开源包。 它允许为 0xcert 协议相关的合同和交易抓取以太坊区块链。
该软件包得到积极维护、良好测试并已在生产环境中使用。 源代码可在 GitHub 上找到,您还可以在其中找到我们的 问题跟踪器。
Installation
运行下面的命令来安装包。
npm install --save web3 @0xcert/ethereum-scanner
此包使用承诺,因此当不支持承诺时,您需要使用 Promise polyfill。
Getting started
初始化 Web3 提供程序。
import * as Web3 from 'web3';
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
加载和解析特定块的数据。
import { Scanner } from '@0xcert/ethereum-scanner';
const blockNumber = 2996066;
const scanner = new Scanner(web3);
await scanner.parse(blockNumber); // => { transactions: [...], contracts: [...]}
API
Scanner Class
Scanner(web3)
允许解析以太坊区块链的主类。
Option | Type | Required | Default | Description |
---|---|---|---|---|
web3 | Web3 | Yes | - | Instance of a Web3 provider. |
注意:扫描器类扩展是一个RawModel类,因此公开了所有相关的辅助方法。
Scanner.prototype.parse(block): Promise(JSON)
用块数据填充扫描器,然后返回序列化的扫描器数据。
Option | Type | Required | Default | Description |
---|---|---|---|---|
block | Integer | Yes | - | Block number. |
Scanner.prototype.populateByBlock(block): Promise(Scanner)
加载和解析以太坊区块链上特定区块的交易和新合约。
Option | Type | Required | Default | Description |
---|---|---|---|---|
block | Integer | Yes | - | Block number. |
License (MIT)
版权所有 (c) 2018 0xcert admin@0xcert.org。
0xcert Ethereum blockchain parser.
This is an open source package for NodeJS written with TypeScript. It allows for scraping of the Ethereum blockchain for 0xcert protocol related contracts and transactions.
This package is actively maintained, well tested and already used in production environments. The source code is available on GitHub where you can also find our issue tracker.
Installation
Run the command below to install the package.
npm install --save web3 @0xcert/ethereum-scanner
This package uses promises thus you need to use Promise polyfill when promises are not supported.
Getting started
Initialize the Web3 provider.
import * as Web3 from 'web3';
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
Load and parse data of a particular block.
import { Scanner } from '@0xcert/ethereum-scanner';
const blockNumber = 2996066;
const scanner = new Scanner(web3);
await scanner.parse(blockNumber); // => { transactions: [...], contracts: [...]}
API
Scanner Class
Scanner(web3)
Main class which allows for parsing the Ethereum blockchain.
Option | Type | Required | Default | Description |
---|---|---|---|---|
web3 | Web3 | Yes | - | Instance of a Web3 provider. |
NOTICE: The scanner class extends is a RawModel class and thus exposes all related helper methods.
Scanner.prototype.parse(block): Promise(JSON)
Populates the scanner with block data and then returns serialized scanner data.
Option | Type | Required | Default | Description |
---|---|---|---|---|
block | Integer | Yes | - | Block number. |
Scanner.prototype.populateByBlock(block): Promise(Scanner)
Loads and parses transactions and new contracts of a particular block on the Ethereum blockchain.
Option | Type | Required | Default | Description |
---|---|---|---|---|
block | Integer | Yes | - | Block number. |
License (MIT)
Copyright (c) 2018 0xcert admin@0xcert.org.