contract AAB{
/* Public variables of the token */
string public name;
string public symbol;
uint8 public decimals;
/* This creates an array with all balances */
mapping (address => uint256) public balanceOf;
/* This generates a public event on the blockchain that will notify clients */
event Transfer(address indexed from, address indexed to, uint256 value);
/* Initializes contract with initial supply tokens to the creator of the contract */
function AAB(uint256 _supply, string _name, string _symbol, uint8 _decimals) {
/* if supply not given then generate 1 million of the smallest unit of the token */
if (_supply == 0) _supply = 1000000;
/* Unless you add other functions these variables will never change */
balanceOf[msg.sender] = _supply;
name = _name;
symbol = _symbol;
/* If you want a divisible token then add the amount of decimals the base unit has */
decimals = _decimals;
}
/* Send coins */
function transfer(address _to, uint256 _value) {
/* if the sender doenst have enough balance then stop */
if (balanceOf[msg.sender] < _value) return;
if (balanceOf[_to] + _value < balanceOf[_to]) return;
/* Add and subtract new balances */
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
/* Notifiy anyone listening that this transfer took place */
Transfer(msg.sender, _to, _value);
}
}
填入代码后,点击右边的Compiler下的Start to compile即可编译写入的代码,如果编译通过,下方会显示相应的合约选项供选择
[ ] 前提准备:
准备好一个存有少量以太坊的账户(可以使用测试网络)。
[ ] 步骤1:
使用Remix编辑自己的合约代码。代码示例如下:
填入代码后,点击右边的Compiler下的Start to compile即可编译写入的代码,如果编译通过,下方会显示相应的合约选项供选择
编辑参数
function AAB(uint256 _supply, string _name, string _symbol, uint8 _decimals)
我们总共定义了四个参数为_supply, _name, _symbol, _decimals 分别表示(发行数量, 全称,符号, 精度)100000,"AlexAB"," €",8