@abridged/contracts 中文文档教程

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

Abridged contracts

NPM 版本GitHub 操作MIT licensed

Installation

$ npm i @abridged/contracts -S

Usage

Javascript

import {
  ContractNames,
  getContractAddress,
  getContractAbiDefinition,
  getContractByteCodeHash,
} from '@abridged/contracts';

console.log(
  'AccountRegistry mainnet address:',
  getContractAddress(ContractNames.AccountRegistry),
);
console.log(
  'AccountRegistry kovan address:',
  getContractAddress(ContractNames.AccountRegistry, '42'),
);
console.log(
  'AccountFriendRecoveryExtension goerli address:',
  getContractAddress(ContractNames.AccountFriendRecoveryExtension, 5),
);
console.log(
  'ERC20Token abi definition:',
  getContractAbiDefinition(ContractNames.ERC20Token),
);
console.log(
  'Account byte code hash:',
  getContractByteCodeHash(ContractNames.Account),
);

可用合约:

NameabibyteCodeHashaddresses
Account
AccountExternalDeposit
AccountRegistry
AccountFriendRecoveryExtension
ERC20Token

Solidity

pragma solidity ^0.5.12;

import {AccountRegistry} from "@abridged/contracts/contracts/account/AccountRegistry.sol";

// ...

Development

Test

$ npm run test

Compile

$ npm run compile

Migrate

配置通过环境变量:

NameDefault value
PROVIDER_MNEMONIC(empty)
PROVIDER_PRIVATE_KEY(empty)
PROVIDER_ENDPOINThttp://localhost:8545
INFURA_PROJECT_ID(empty)

脚本:

$ npm run migrate:main
$ npm run migrate:ropsten
$ npm run migrate:rinkeby
$ npm run migrate:goerli
$ npm run migrate:kovan
$ npm run migrate:local

Build dist

$ npm run dist

Initialize

通过环境变量配置:

NameDefault value
PROVIDER_MNEMONIC(empty)
PROVIDER_PRIVATE_KEY(empty)
PROVIDER_ENDPOINThttp://localhost:8545
INFURA_PROJECT_ID(empty)
PAYMENT_GUARDIAN_ADDRESS(empty)

脚本:

$ npm run initialize:main
$ npm run initialize:ropsten
$ npm run initialize:rinkeby
$ npm run initialize:goerli
$ npm run initialize:kovan
$ npm run initialize:local

License

MIT

Abridged contracts

NPM versionGitHub actionsMIT licensed

Installation

$ npm i @abridged/contracts -S

Usage

Javascript

import {
  ContractNames,
  getContractAddress,
  getContractAbiDefinition,
  getContractByteCodeHash,
} from '@abridged/contracts';

console.log(
  'AccountRegistry mainnet address:',
  getContractAddress(ContractNames.AccountRegistry),
);
console.log(
  'AccountRegistry kovan address:',
  getContractAddress(ContractNames.AccountRegistry, '42'),
);
console.log(
  'AccountFriendRecoveryExtension goerli address:',
  getContractAddress(ContractNames.AccountFriendRecoveryExtension, 5),
);
console.log(
  'ERC20Token abi definition:',
  getContractAbiDefinition(ContractNames.ERC20Token),
);
console.log(
  'Account byte code hash:',
  getContractByteCodeHash(ContractNames.Account),
);

Available contracts:

NameabibyteCodeHashaddresses
Account
AccountExternalDeposit
AccountRegistry
AccountFriendRecoveryExtension
ERC20Token

Solidity

pragma solidity ^0.5.12;

import {AccountRegistry} from "@abridged/contracts/contracts/account/AccountRegistry.sol";

// ...

Development

Test

$ npm run test

Compile

$ npm run compile

Migrate

Config via env vars:

NameDefault value
PROVIDER_MNEMONIC(empty)
PROVIDER_PRIVATE_KEY(empty)
PROVIDER_ENDPOINThttp://localhost:8545
INFURA_PROJECT_ID(empty)

Scripts:

$ npm run migrate:main
$ npm run migrate:ropsten
$ npm run migrate:rinkeby
$ npm run migrate:goerli
$ npm run migrate:kovan
$ npm run migrate:local

Build dist

$ npm run dist

Initialize

Config via env vars:

NameDefault value
PROVIDER_MNEMONIC(empty)
PROVIDER_PRIVATE_KEY(empty)
PROVIDER_ENDPOINThttp://localhost:8545
INFURA_PROJECT_ID(empty)
PAYMENT_GUARDIAN_ADDRESS(empty)

Scripts:

$ npm run initialize:main
$ npm run initialize:ropsten
$ npm run initialize:rinkeby
$ npm run initialize:goerli
$ npm run initialize:kovan
$ npm run initialize:local

License

MIT

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