EOS私有网络发行代币

1.进入github上clone下来的eos目录

$ cd ~/eos

2.创建eosio.token

$ cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

executed transaction: 29abbafdd8c01c4895db000d2c30338462cf2792b7f5ca55c94544e46167d91e 200 bytes 360 us # eosio <= eosio::newaccount "0000000000ea305500a6823403ea305501000000010002c0ded2bc1f1305fb0faac5e6c03ee3a1924234985427b6167ca56... warning: transaction executed locally, but may not be confirmed by the network yet ]

3.添加eosio.bios合约

eosio.bios合约用于控制资源分配和权限管理

cleos set contract eosio build/contracts/eosio.bios -p eosio@active

4.部署token合约

$ cleos set contract eosio.token build/contracts/eosio.token -p eosio.token

Reading WASM from build/contracts/eosio.token/eosio.token.wasm... Publishing contract... executed transaction: 894586b86e0489e125a425c0cfe5af23e4d1f35748c9df2d74e228dd0a370907 8104 bytes 1907 us # eosio <= eosio::setcode "00a6823403ea305500009594010061736d01000000017e1560037f7e7f0060057f7e7e7f7f0060047f7e7f7f00600000600... # eosio <= eosio::setabi "00a6823403ea3055b4030e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6505087472616... warning: transaction executed locally, but may not be confirmed by the network yet ] -p,–permission TEXT 表示授权账号,该合约授权给eosio.token账号。
代币合约eosio.token能让许多不同的代币同时在一个智能合约上发行,但是却能被不同用户管理。

5.创建代币

$ cleos push action eosio.token create '[ "eosio.token", "1000000000.0000 SYS"]' -p eosio.token

executed transaction: 50506b4723126945574fdee524c34f4bf349988fbcc4d015a35c0fb0ff9cdb5e 120 bytes 442 us # eosio.token <= eosio.token::create {"issuer":"eosio","maximum_supply":"1000000000.0000 SYS"} warning: transaction executed locally, but may not be confirmed by the network yet ]

create 函数是用来新建一种代币,并输入代币的各种属性,同时 create 函数也是一个 action。action 是 eos 智能合约的接口函数,定义外界可以对智能合约做什么动作。 结合操作命令,说明各个参数的定义: create(
account_name issuer,/发行方账号的名称为”eosio”/
asset maximum_supply,/总供应量为10亿和代币名称/

6.发行代币

$ cleos push action eosio.token issue '[ "111111111111", "10000.0000 SYS", "first SYS issue" ]' -p eosio.token

executed transaction: 87ad76b03fbace95ec435d22d474dffd402d571e51b31bf31f5fd9a2a057aca9 144 bytes 1846 us # eosio.token <= eosio.token::issue {"to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio.token <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # eosio <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"} # 111111111111 <= eosio.token::transfer {"from":"eosio","to":"111111111111","quantity":"10000.0000 SYS","memo":"first ColorBayToken issue"}

issue action 来获得代币。
void issue( account_name to, /代币的发行方为账户/
asset quantity, /发行代币的数量为10000个,代币名称为CBT/
string memo ); /表示备注说明,不能超过256个字节/

7.转账

创建账户可参考这里

$ cleos push action eosio.token transfer '[ "111111111111", "111111111112", "8000.0000 SYS", "pay!" ]' -p 111111111111

transfer action 来获得代币。
void transfer(
account_name from, /转账方/
account_name to, /接收方/
asset quantity, /转账的数量/
string memo ); /表示备注说明,不能超过256个字节/

发表评论

电子邮件地址不会被公开。 必填项已用*标注