根据官网开发文档实际操作即可。
https://developers.eos.io/eosio-home/docs
https://zhuanlan.zhihu.com/p/37891815
cleos
钱包
cleos wallet create --to-console
cleos wallet open
cleos wallet list
cleos wallet unlock
cleos wallet create_key
warn 2018-11-27T02:58:55.049 thread-0 wallet.cpp:223 save_wallet_file ] saving wallet to file /root/eosio-wallet/./default.wallet
Created new private key with a public key of: "EOS6erobkNLjYFzUbfr2P778kHrRo5P7d5b5tMMShVgoQ92P7g2Mo"
cleos wallet import
You'll be prompted for a private key, enter the eosio development key provided below
5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
账户
cleos create key -f myKey.txt
cleos create account [OPTIONS] creator name OwnerKey ActiveKey
If the system contract is loaded, (for example a production network) then use cleos system newaccountinstead
cleos create account eosio bob EOS72iMnMyaADjELbrAe3f9fUmKe6aEUqr6Hypa3wpVpAry1b3wHQ EOS8Yxz5xQnELbg4yosR5CLeUA3kdF4fiM4CEX2fFyHL4yZ2gQBCj
cleos create account eosio bob123 EOS6erobkNLjYFzUbfr2P778kHrRo5P7d5b5tMMShVgoQ92P7g2Mo
cleos create account eosio alice EOS6erobkNLjYFzUbfr2P778kHrRo5P7d5b5tMMShVgoQ92P7g2Mo
合约
编译
eosio-cpp -o hello.wasm hello.cpp --abigen
创建自己的合约账户
cleos create account eosio hello EOS6erobkNLjYFzUbfr2P778kHrRo5P7d5b5tMMShVgoQ92P7g2Mo -p eosio@active
部署代币合约
cleos set contract hello /root/contract/hello -p hello@active
调用合约方法
cleos push action hello hi '["bob"]' -p alice@active
权限验证
Use the require_auth method. This method takes an name as a parameter, and will check if the user executing the action matches the provided paramter.
cleos push action hello hi '["alice123"]' -p alice@active
Error 3090004: Missing required authority
Ensure that you have the related authority inside your transaction!;
If you are currently using 'cleos push action' command, try to add the relevant authority using -p option.
使用 eos 已有代码部署合约
开发者公钥,合约 eosio.token
cleos create account eosio eosio.token EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
编译
eosio-cpp -I include -o eosio.token.wasm src/eosio.token.cpp --abigen
部署
cleos set contract eosio.token /root/contract/eosio.contracts/eosio.token --abi eosio.token.abi -p eosio.token@active
发币
发行新代币 SYS,1000000000.0000 个
Create the Token 创建新 token
cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active
发行向 Alice issue 100 SYS
cleos push action eosio.token issue '[ "alice", "100.0000 SYS", "memo" ]' -p eosio@active
开发调试选项
To inspect the transaction, try using the -d -j options, they indicate "don't broadcast" and "return transaction as json," which you may find useful during development.
cleos push action eosio.token issue '["alice", "100.0000 SYS", "memo"]' -p eosio@active -d -j
{
"expiration": "2018-11-27T04:01:52",
"ref_block_num": 8647,
"ref_block_prefix": 4181672008,
"max_net_usage_words": 0,
"max_cpu_usage_ms": 0,
"delay_sec": 0,
"context_free_actions": [],
"actions": [{
"account": "eosio.token",
"name": "issue",
"authorization": [{
"actor": "eosio",
"permission": "active"
}
],
"data": "0000000000855c3440420f00000000000453595300000000046d656d6f"
}
],
"transaction_extensions": [],
"signatures": [
"SIG_K1_JzGca5sVkd9ZpPC2vK5oQaSTKmA9CmHLFYdJkswEjLpYCA8iK1msnsW7Cricf7RNvTczJcWYDnUZQ6WJb9S2j7smrHxZaf"
],
"context_free_data": []
}
转账 Alice 向 bob 转 25 个 SYS
cleos push action eosio.token transfer '[ "alice", "bob", "25.0000 SYS", "m" ]' -p alice@active
查询账户余额
https://developers.eos.io/eosio-cleos/reference#currency-balance
cleos get currency balance eosio.token bob SYS
25.00 SYS
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于