@0xcert/ethereum-erc20 中文文档教程
这是一个完整的实现ERC-20 用于以太坊区块链的可替代令牌标准。 这是一个使用 Truffle 框架构建的开源项目。
此实施的目的是为任何想要在以太坊区块链上使用和开发可替代代币的人提供一个良好的起点。 您可以使用经过多次审核的代码,而不是自己重新实现 ERC-20,我们希望它能在未来被社区广泛使用。
Structure
由于这是一个 Truffle 项目,您将在 contracts/tokens/
目录中找到所有令牌。
Requirements
- NodeJS 9.0+ recommended.
- Windows, Linux or Mac OS X.
Installation
NPM
这是 NPM 模块,用于 Truffle 框架。 为了将它用作 Javascript 项目中的依赖项,您必须通过 npm
命令安装它:
$ npm install @0xcert/ethereum-erc20
Source
克隆存储库并安装所需的 npm
依赖项:
$ git clone git@github.com:0xcert/ethereum-erc20.git
$ cd ethereum-erc20
$ npm install
确保一切已正确设置:
$ npm run test
Usage
NPM
要在 JavaScript 代码中与包的合约进行交互,您只需需要该包的 .json 文件:
const contract = require("@0xcert/ethereum-erc20/build/contracts/Token.json");
console.log(contract);
Source
Creating smart contract
最简单的开始方法是在 contracts/tokens/
下创建一个新文件(例如 MyToken.sol
):
pragma solidity ^0.4.24;
import "../tokens/Token.sol";
contract MyToken is Token {
constructor()
public
{
tokenName = "My Token";
tokenSymbol = "MTK";
tokenDecimals = 18;
tokenTotalSupply = 100000000000000000000000000;
balances[msg.sender] = totalTokenSupply; // Give the owner of the contract the whole balance
}
}
就是这样。 让我们编译合约:
$ npm run compile
在本地部署它并开始与合约交互(铸造和转移代币)的最简单方法是使用 甘那许。 按照 此处 描述的 Truffle 文档中的步骤进行操作。
Contributing
请参阅 CONTRIBUTING.md 了解如何提供帮助。
Licence
有关详细信息,请参阅许可证。
This is a complete implementation of the ERC-20 fungible token standard for the Ethereum blockchain. This is an open source project build with Truffle framework.
Purpose of this implementation is to provide a good starting point for anyone who wants to use and develop fungible tokens on the Ethereum blockchain. Instead of re-implementing the ERC-20 yourself you can use this code which has gone through multiple audits and we hope it will be extensively used by the community in the future.
Structure
Since this is a Truffle project, you will find all tokens in contracts/tokens/
directory.
Requirements
- NodeJS 9.0+ recommended.
- Windows, Linux or Mac OS X.
Installation
NPM
This is an NPM module for Truffle framework. In order to use it as a dependency in your Javascript project, you must install it through the npm
command:
$ npm install @0xcert/ethereum-erc20
Source
Clone the repository and install the required npm
dependencies:
$ git clone git@github.com:0xcert/ethereum-erc20.git
$ cd ethereum-erc20
$ npm install
Make sure that everything has been set up correctly:
$ npm run test
Usage
NPM
To interact with package's contracts within JavaScript code, you simply need to require that package's .json files:
const contract = require("@0xcert/ethereum-erc20/build/contracts/Token.json");
console.log(contract);
Source
Creating smart contract
The easiest way to start is to create a new file under contracts/tokens/
(e.g. MyToken.sol
):
pragma solidity ^0.4.24;
import "../tokens/Token.sol";
contract MyToken is Token {
constructor()
public
{
tokenName = "My Token";
tokenSymbol = "MTK";
tokenDecimals = 18;
tokenTotalSupply = 100000000000000000000000000;
balances[msg.sender] = totalTokenSupply; // Give the owner of the contract the whole balance
}
}
That's it. Let's compile the contract:
$ npm run compile
The easiest way to deploy it locally and start interacting with the contract (minting and transferring tokens) is to deploy it on your personal (local) blockchain using Ganache. Follow the steps in the Truffle documentation which are described here.
Contributing
See CONTRIBUTING.md for how to help out.
Licence
See LICENSE for details.