EOS 部署 Token 合约

获取合约源码

# 进入自己的合约目录
cd /Users/mac/eos/contracts

# 获取源码
git clone https://github.com/EOSIO/eosio.contracts --branch v1.4.0 --single-branch

cd eosio.contracts/eosio.token

创建合约账户

cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV

如果没钱包没解锁,先解锁:

cleos wallet unlock
# 输入创建钱包时的密码

编译合约

eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen

部署合约

cleos set contract eosio.token /Users/mac/eos/contracts/eosio.contracts/eosio.token --abi eosio.token.abi -p eosio.token@active

# 输出结果
Reading WASM from /Users/mac/eos/contracts/eosio.contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: a2a22462e687e04bbafaff3e960875d3ddd24da59222b52f2c280372f7a9d7a9  9304 bytes  24424 us
#         eosio <= eosio::setcode               {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d0100000001aa011c60037f7e7f0060047f...
#         eosio <= eosio::setabi                {"account":"eosio.token","abi":"0e656f73696f3a3a6162692f312e310008076163636f756e7400010762616c616e63...

创建 Token

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

# 输出结果
executed transaction: ca6702172a730339328387e1828446328df5c279b4b13917e333216875ae93e1  120 bytes  4270 us
#   eosio.token <= eosio.token::create          {"issuer":"eosio","maximum_supply":"1000000000.0000 SYS"}

发行 Token

cleos push action eosio.token issue '[ "alice", "100.0000 SYS", "memo" ]' -p eosio@active

输出结果:

executed transaction: ce6b060ccbe90d514e5b2c5eaa705937943a0422bac947abe9285104187676f2  128 bytes  7300 us
#   eosio.token <= eosio.token::issue           {"to":"alice","quantity":"100.0000 SYS","memo":"memo"}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"alice","quantity":"100.0000 SYS","memo":"memo"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"alice","quantity":"100.0000 SYS","memo":"memo"}
#         alice <= eosio.token::transfer        {"from":"eosio","to":"alice","quantity":"100.0000 SYS","memo":"memo"}

转账

cleos push action eosio.token transfer '[ "alice", "bob", "25.0000 SYS", "m" ]' -p alice@active

输出:

executed transaction: 055ede176cbc99fcc4e411c0cd8d571317be4e4b130ea046fe49f6af7ad49443  128 bytes  2434 us
#   eosio.token <= eosio.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"m"}
#         alice <= eosio.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"m"}
#           bob <= eosio.token::transfer        {"from":"alice","to":"bob","quantity":"25.0000 SYS","memo":"m"}

查看余额

查看 alice 和 bob 的 balance:

cleos get currency balance eosio.token bob SYS
# 结果
25.00 SYS25.0000 SYS

cleos get currency balance eosio.token alice SYS
# 结果
75.0000 SYS

官方文档:
https://developers.eos.io/eosio-home/docs/token-contract

你可能感兴趣的:(EOS 部署 Token 合约)