首先需要切换到eos/build/programs/cleos
1 钱包设置
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos wallet create
"/Users/wsilverky/Documents/gitTools/eos/eos/build/programs/keosd/keosd" launched
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5JWkf19kjUybLgpHD5LXNgcSc9oqh5Cs7CSggEUbVu1sDZ16Jmg"
PS:需要保存好私钥
wsilverkydeMacBook-Pro:cleos wsilverky$ vi ~/Desktop/eosPriviteKey.txt
wsilverkydeMacBook-Pro:cleos wsilverky$ cat ~/Desktop/eosPriviteKey.txt
PW5JWkf19kjUybLgpHD5LXNgcSc9oqh5Cs7CSggEUbVu1sDZ16Jmg
2 为账号部署合约
另开个终端启动节点服务器:
wsilverkydeMacBook-Pro:config wsilverky$ cd ~/Documents/gitTools/eos/eos/build/programs/nodeos/
wsilverkydeMacBook-Pro:nodeos wsilverky$ ./nodeos
部署合约:
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos set contract eosio ../../contracts/eosio.bios -p eosio
Reading WAST/WASM from ../../contracts/eosio.bios/eosio.bios.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: effe553e4367e02b673b2ca6a4959a24d749b6dbdb99da87d24762c99b6756be 3720 bytes 5193 us
# eosio <= eosio::setcode {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001621260037f7e7f0060057f7e7e7e7e...
# eosio <= eosio::setabi {"account":"eosio","abi":"0e656f73696f3a3a6162692f312e30050c6163636f756e745f6e616d65046e616d650f7065...
warning: transaction executed locally, but may not be confirmed by the network yet
3 创建2个key,导入key的私钥
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos create key
Private key: 5Jf39VYK2HLyZdXgVYYSjQ9iKgkGs8BQPrUmq567Bc4V3i7MpiK
Public key: EOS5sLrJyeX1nWc8xd8thB7DD1apCa872DjU8Dfn4sYLprmd7GLZa
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos create key
Private key: 5JUzSB4TgSZkLWxnYPNiw4fs3bBo839hdZg5S6ScvJKCoPeLUte
Public key: EOS8DGpDx2Xyi5gCAGKR2QfNZpayrsfJYb3u913upX4a3aGrnGYX1
1.1.0版本上添加私钥方法改变:
cleos wallet import --private-key 5JXmv5N4hTgDc6NVS6J8CNT1JxDKab7M6iEyFbPewTrGkUxhuuZ -n alec_wallet
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos wallet import 5Jf39VYK2HLyZdXgVYYSjQ9iKgkGs8BQPrUmq567Bc4V3i7MpiK
imported private key for: EOS5sLrJyeX1nWc8xd8thB7DD1apCa872DjU8Dfn4sYLprmd7GLZa
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos wallet import 5JUzSB4TgSZkLWxnYPNiw4fs3bBo839hdZg5S6ScvJKCoPeLUte
imported private key for: EOS8DGpDx2Xyi5gCAGKR2QfNZpayrsfJYb3u913upX4a3aGrnGYX1
4 根据生成的公钥,创建账号
账号名称为:accounttest
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos create account eosio accounttest EOS5sLrJyeX1nWc8xd8thB7DD1apCa872DjU8Dfn4sYLprmd7GLZa EOS8DGpDx2Xyi5gCAGKR2QfNZpayrsfJYb3u913upX4a3aGrnGYX1
executed transaction: 305e584b256ec9c91332c2ad0bc9b5137f2935a5daf6cba2569ca8cbb0e4a2ca 200 bytes 292 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"accounttest","owner":{"threshold":1,"keys":[{"key":"EOS5sLrJyeX1nWc8xd8th...
warning: transaction executed locally, but may not be confirmed by the network yet
5 查看账号信息
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get account accounttest -j
{
"account_name": "accounttest",
"privileged": false,
"last_code_update": "1970-01-01T00:00:00.000",
"created": "2018-06-04T17:15:40.000",
"ram_quota": -1,
"net_weight": -1,
"cpu_weight": -1,
"net_limit": {
"used": -1,
"available": -1,
"max": -1
},
"cpu_limit": {
"used": -1,
"available": -1,
"max": -1
},
"ram_usage": 2724,
"permissions": [{
"perm_name": "active",
"parent": "owner",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS8DGpDx2Xyi5gCAGKR2QfNZpayrsfJYb3u913upX4a3aGrnGYX1",
"weight": 1
}
],
"accounts": [],
"waits": []
}
},{
"perm_name": "owner",
"parent": "",
"required_auth": {
"threshold": 1,
"keys": [{
"key": "EOS5sLrJyeX1nWc8xd8thB7DD1apCa872DjU8Dfn4sYLprmd7GLZa",
"weight": 1
}
],
"accounts": [],
"waits": []
}
}
],
"total_resources": null,
"delegated_bandwidth": null,
"voter_info": null
}
PS:-j表示json输出
6 检测,并部署合约
在做部署前,需要先解锁钱包
./cleos wallet unlock -n default --password PW5JWkf19kjUybLgpHD5LXNgcSc9oqh5Cs7CSggEUbVu1sDZ16Jmg
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos wallet unlock -n default --password PW5JWkf19kjUybLgpHD5LXNgcSc9oqh5Cs7CSggEUbVu1sDZ16Jmg
Unlocked: default
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get code accounttest
code hash: 0000000000000000000000000000000000000000000000000000000000000000
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos set contract accounttest ../../contracts/eosio.token/
Reading WAST/WASM from ../../contracts/eosio.token/eosio.token.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 7bfd56de49e25a0f533ed40578c9f57a6784d65ae6090e2e5f969c59a7c94f27 8104 bytes 1489 us
# eosio <= eosio::setcode {"account":"accounttest","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7e...
# eosio <= eosio::setabi {"account":"accounttest","abi":"0e
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get code accounttest
code hash: 641f336aa1d08526201599c3c0ddb7a646e5ac8f9fd2493f56414d0422a0f957
7 创建货币
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos push action accounttest create '{"issuer":"accounttest","maximum_supply":"100000.0000 CUR","can_freeze":"0","can_recall":"0","can_whitelist":"0"}' --permission accounttest@active
executed transaction: 4a6582e95a803be7650f9604d7231f9510b441397ab7125c9b812105261c251c 120 bytes 3339 us
# accounttest <= accounttest::create {"issuer":"accounttest","maximum_supply":"100000.0000 CUR"}
warning: transaction executed locally, but may not be confirmed by the network yet
8 发行货币
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos push action accounttest issue '{"to":"accounttest","quantity":"1000.0000 CUR","memo":""}' --permission accounttest@active -j
{
"transaction_id": "8bf68c54b1e58bf6b06270817a333db353af7f5826477c6d0fc4f4aaa44fca96",
"processed": {
"id": "8bf68c54b1e58bf6b06270817a333db353af7f5826477c6d0fc4f4aaa44fca96",
"receipt": {
"status": "executed",
"cpu_usage_us": 1429,
"net_usage_words": 15
},
"elapsed": 1429,
"net_usage": 120,
"scheduled": false,
"action_traces": [{
"receipt": {
"receiver": "accounttest",
"act_digest": "770eb3e94ccb5bd28db99e611ba26ecb43a50dd078e89ceada755dfa0ef2de9f",
"global_sequence": 12857,
"recv_sequence": 2,
"auth_sequence": [[
"accounttest",
4
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "accounttest",
"name": "issue",
"authorization": [{
"actor": "accounttest",
"permission": "active"
}
],
"data": {
"to": "accounttest",
"quantity": "1000.0000 CUR",
"memo": ""
},
"hex_data": "003256394f4d11328096980000000000044355520000000000"
},
"elapsed": 1207,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "8bf68c54b1e58bf6b06270817a333db353af7f5826477c6d0fc4f4aaa44fca96",
"inline_traces": []
}
],
"except": null
}
}
PS:注意创建的数字精度要匹配
9 查看账号信息
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get table accounttest accounttest accounts
{
"rows": [{
"balance": "1000.0000 CUR"
}
],
"more": false
}
10 转账
可使用上述方法再创建eosio账号进行转账处理
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos push action accounttest transfer '{"from":"accounttest","to":"eosio","quantity":"50.0000 CUR","memo":"first transfer"}' -p accounttest@active -j
{
"transaction_id": "3986197951ecfa397e52f03f91d3717f764cbb8a01dc6a8f3281ae125fc6ca7e",
"processed": {
"id": "3986197951ecfa397e52f03f91d3717f764cbb8a01dc6a8f3281ae125fc6ca7e",
"receipt": {
"status": "executed",
"cpu_usage_us": 870,
"net_usage_words": 18
},
"elapsed": 870,
"net_usage": 144,
"scheduled": false,
"action_traces": [{
"receipt": {
"receiver": "accounttest",
"act_digest": "3c4f8bbd71db5fb4e82663f7785c1b835912c6f97ad091eaa7a7fc769bc24bfa",
"global_sequence": 13915,
"recv_sequence": 3,
"auth_sequence": [[
"accounttest",
5
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "accounttest",
"name": "transfer",
"authorization": [{
"actor": "accounttest",
"permission": "active"
}
],
"data": {
"from": "accounttest",
"to": "eosio",
"quantity": "50.0000 CUR",
"memo": "first transfer"
},
"hex_data": "003256394f4d11320000000000ea305520a107000000000004435552000000000e6669727374207472616e73666572"
},
"elapsed": 624,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "3986197951ecfa397e52f03f91d3717f764cbb8a01dc6a8f3281ae125fc6ca7e",
"inline_traces": [{
"receipt": {
"receiver": "eosio",
"act_digest": "3c4f8bbd71db5fb4e82663f7785c1b835912c6f97ad091eaa7a7fc769bc24bfa",
"global_sequence": 13916,
"recv_sequence": 13913,
"auth_sequence": [[
"accounttest",
6
]
],
"code_sequence": 1,
"abi_sequence": 1
},
"act": {
"account": "accounttest",
"name": "transfer",
"authorization": [{
"actor": "accounttest",
"permission": "active"
}
],
"data": {
"from": "accounttest",
"to": "eosio",
"quantity": "50.0000 CUR",
"memo": "first transfer"
},
"hex_data": "003256394f4d11320000000000ea305520a107000000000004435552000000000e6669727374207472616e73666572"
},
"elapsed": 63,
"cpu_usage": 0,
"console": "",
"total_cpu_usage": 0,
"trx_id": "3986197951ecfa397e52f03f91d3717f764cbb8a01dc6a8f3281ae125fc6ca7e",
"inline_traces": []
}
]
}
],
"except": null
}
}
转账后查询账号信息
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get table accounttest accounttest accounts
{
"rows": [{
"balance": "950.0000 CUR"
}
],
"more": false
}