本文用的是Remix+MetaMask开发代币。
在线编辑器网站:https://remix.ethereum.org/#optimize=false&version=soljson-v0.5.1+commit.c8a2cb62.js
在谷歌上安装MetaMask插件。
基础代币的合约:
pragma solidity >=0.4.22 <0.6.0;
interface tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external;
}
contract TokenERC20 {
string public name;// Public variables of the token
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply; // 18 decimals is the strongly suggested default, avoid changing it
mapping (address => uint256) public balanceOf; // This creates an array with all balances
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value); // This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);// This generates a public event on the blockchain that will notify clients
event Burn(address indexed from, uint256 value); // This notifies clients about the amount burnt
/**
* Constructor function
*
* Init