@0xcert/erc721-validator 中文文档教程

发布于 3年前 浏览 24 项目主页 更新于 3年前

npm version

以太坊 ERC-721 合约验证器。

这是一个用 TypeScript 编写的 NodeJS 开源包。 它允许根据一系列测试来验证合约,以检查其是否符合 ERC-721 标准。

该软件包得到积极维护、良好测试并已在生产环境中使用。 源代码可在 GitHub 上找到,您还可以在其中找到我们的 问题跟踪器

How it works

有关验证器如何工作的更多信息,请查看文章解释技术

Installation

运行下面的命令来安装包。

npm install --save web3 erc721-validator

此包使用承诺,因此当不支持承诺时,您需要使用 Promise polyfill

Getting started

初始化 Web3 提供程序。

import * as Web3 from 'web3';

const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));

加载和解析特定块的数据。

import { Validator } from 'erc721-validator';

const validator = new ERC721Validator(web3);
const contract  = '0x...';
const token     = '123';
const giver     = '0x...';

await validator.basic(test, contract);                  // => [{...},{...},{...},{...}]
await validator.token(test, contract, token);           // => [{...},{...},{...},{...}]
await validator.transfer(test, contract, token, giver); // => [{...},{...},{...},{...}]

API

ERC721Validator Class

ERC721Validator(web3)

允许测试合约有效性的主类。

OptionTypeRequiredDefaultDescription
web3Web3Yes-Instance of a Web3 provider.

注意: ERC721Validator 类扩展为 RawModel 类,因此公开了所有相关的辅助方法。

ERC721Validator.prototype.basic(contract): Promise(JSON)

执行一系列基本合约测试。

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address

ERC721Validator.prototype.token(contract, tokenId): Promise(JSON)

执行一系列测试以验证合约令牌的合规性。

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address
tokenIdStringYes-Token ID

ERC721Validator.prototype.transfer(contract, tokenId, giver): Promise(JSON)

执行一系列测试以验证合约令牌传输的合规性。

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address
tokenIdStringYes-Token ID
giverStringYes-Address of giver

License (MIT)

版权所有 (c) 2018 0xcert admin@0xcert.org

npm version

Ethereum ERC-721 Contract Validator.

This is an open source package for NodeJS written with TypeScript. It allows for validating a contract against a series of tests to check its compliancy with the ERC-721 standard.

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.

How it works

For more information on how the validator works please check the article explaining the technique.

Installation

Run the command below to install the package.

npm install --save web3 erc721-validator

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 { Validator } from 'erc721-validator';

const validator = new ERC721Validator(web3);
const contract  = '0x...';
const token     = '123';
const giver     = '0x...';

await validator.basic(test, contract);                  // => [{...},{...},{...},{...}]
await validator.token(test, contract, token);           // => [{...},{...},{...},{...}]
await validator.transfer(test, contract, token, giver); // => [{...},{...},{...},{...}]

API

ERC721Validator Class

ERC721Validator(web3)

Main class which allows for testing your contract validity.

OptionTypeRequiredDefaultDescription
web3Web3Yes-Instance of a Web3 provider.

NOTICE: The ERC721Validator class extends is a RawModel class and thus exposes all related helper methods.

ERC721Validator.prototype.basic(contract): Promise(JSON)

Performes a series of basic contract tests.

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address

ERC721Validator.prototype.token(contract, tokenId): Promise(JSON)

Performes a series of tests to validate contract token compliancy.

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address
tokenIdStringYes-Token ID

ERC721Validator.prototype.transfer(contract, tokenId, giver): Promise(JSON)

Performes a series of tests to validate contract token transfer compliancy.

OptionTypeRequiredDefaultDescription
contractStringYes-Contract Address
tokenIdStringYes-Token ID
giverStringYes-Address of giver

License (MIT)

Copyright (c) 2018 0xcert admin@0xcert.org.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文