在执行以下操作前要保证EOS本地环境是OK的,可参考上一篇环境搭建。https://www.jianshu.com/p/3f7c225aa80a
#接下来先启动必要的服务
#1、启动keosd
./keosd --http-server-address=localhost:8899
#2、启动nodeos
./nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
#3、创建钱包
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet create -n terrywallet --to-console
#成功提示:
Creating wallet: terrywallet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
#钱包密码,用于解锁钱包,妥善保管
"PW5JfV9vXC6oARtpmAh7sghUefoMzKCGBBE7XaZB3jm6e7PRfFEAT"
#4、查看当前钱包,标注*的表示已经解锁
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet list
Wallets:
[
"terrywallet *",
"testwallet *"
]
#5、创建公/私钥
#5.1私钥1:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create key --to-console
#成功提示:
Private key: 5KgXh9p4Zk6fXk5JwU3es4gaRw7nChci1fVw4LFGEQ3JuCAQGYM
Public key: EOS6kTXS42XaMgdv9gxmhkssuhZqRY353F3HRoxqP6pH9W3v7SUNQ
#5.2私钥2:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create key --to-console
#成功提示:
Private key: 5JvJtgdY5PYVyZPzMBsJv43VTj4A5dJbatXsCAr5urYMEStUxqm
Public key: EOS7QTNAyt6EGZED4s8deU8pfcwPVDnNXcFmZ6rkCbiRm2HFdfBFm
#5.3私钥3:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create key --to-console
#成功提示:
Private key: 5Hzk4p3miNM4arWtprUNw3PARV4EeoEp93YJXcSFuoJ6ugZvvH2
Public key: EOS6YRGgBZxTiXcEW2kgUrbk97AjtzNHghq9G6vgeLXrARRonvyqV
#6、导入私钥到钱包
#6.1导入私钥1
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet import --private-key 5KgXh9p4Zk6fXk5JwU3es4gaRw7nChci1fVw4LFGEQ3JuCAQGYM -n terrywallet
#导入成功提示:
imported private key for: EOS6kTXS42XaMgdv9gxmhkssuhZqRY353F3HRoxqP6pH9W3v7SUNQ
#6.2导入私钥2
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet import --private-key 5JvJtgdY5PYVyZPzMBsJv43VTj4A5dJbatXsCAr5urYMEStUxqm -n terrywallet
#导入成功提示:
imported private key for: EOS7QTNAyt6EGZED4s8deU8pfcwPVDnNXcFmZ6rkCbiRm2HFdfBFm
#6.3导入私钥3
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet import --private-key 5Hzk4p3miNM4arWtprUNw3PARV4EeoEp93YJXcSFuoJ6ugZvvH2 -n terrywallet
#成功提示
imported private key for: EOS6YRGgBZxTiXcEW2kgUrbk97AjtzNHghq9G6vgeLXrARRonvyqV
#6.4导入EOSIO超级账户私钥到钱包
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -n terrywallet
#导入成功提示:
imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
#7、查看公钥列表
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet keys
[
"EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"EOS6YRGgBZxTiXcEW2kgUrbk97AjtzNHghq9G6vgeLXrARRonvyqV",
"EOS6kTXS42XaMgdv9gxmhkssuhZqRY353F3HRoxqP6pH9W3v7SUNQ",
"EOS7QTNAyt6EGZED4s8deU8pfcwPVDnNXcFmZ6rkCbiRm2HFdfBFm"
]
#8、创建账户
#8.1terryinfo123
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create account eosio terryinfo123 EOS6kTXS42XaMgdv9gxmhkssuhZqRY353F3HRoxqP6pH9W3v7SUNQ
#成功提示:
executed transaction: 7bdb733ec686f9f6627c5e60cbb71b27e05fc408ed49032aaee1e202d811c0a3 200 bytes 367 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"terryinfo123","owner":{"threshold":1,"keys":[{"key":"EOS6kTXS42XaMgdv9gxm...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#8.2terryinfo124
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create account eosio terryinfo124 EOS7QTNAyt6EGZED4s8deU8pfcwPVDnNXcFmZ6rkCbiRm2HFdfBFm
#成功提示:
executed transaction: a3727c3f4bf68d31a002efd2cb99bdc283704acb220902f41e1af2e3100a9254 200 bytes 216 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"terryinfo124","owner":{"threshold":1,"keys":[{"key":"EOS7QTNAyt6EGZED4s8d...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#8.3terryinfo125
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos create account eosio terryinfo125 EOS6YRGgBZxTiXcEW2kgUrbk97AjtzNHghq9G6vgeLXrARRonvyqV
executed transaction: 4380cf8121e27c837a3348a8011a85f9b4d1c429844b5e64da2c6c67aabc9239 200 bytes 206 us
# eosio <= eosio::newaccount {"creator":"eosio","name":"terryinfo125","owner":{"threshold":1,"keys":[{"key":"EOS6YRGgBZxTiXcEW2kg...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#9、用terryinfo123账户部署智能合约
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos set contract terryinfo123 ~/eos/build/contracts/eosio.token/ -p terryinfo123
#成功提示:
Reading WASM from /home/terry/eos/build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: fec639822cdb823543ca26f58db0712756d05465023ffe69c79cfa1d3f4a3b2c 8112 bytes 7108 us
# eosio <= eosio::setcode {"account":"terryinfo123","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7...
# eosio <= eosio::setabi {"account":"terryinfo123","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#10、创建代币UFO,发行1亿个
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos push action terryinfo123 create '["eosio", "100000000.0000 UFO", 0, 0, 0]' -p terryinfo123
#成功提示:
executed transaction: d55c875cfd28be2ef4a994b77ccf6983c3865edeab111821026129646d23f2cc 120 bytes 3005 us
# terryinfo123 <= terryinfo123::create {"issuer":"eosio","maximum_supply":"100000000.0000 UFO"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
#11、把代币转给发行账户
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos push action terryinfo123 issue '["terryinfo124", "100000000.0000 UFO", "terryinfo123 to terryinfo124 1个亿UFO"]' -p eosio
#成功提示:
executed transaction: 2b997802281248262a1ef0571b12cef6a5d1183150789199abe5f216d95d22b8 160 bytes 1091 us
# terryinfo123 <= terryinfo123::issue {"to":"terryinfo124","quantity":"100000000.0000 UFO","memo":"terryinfo123 to terryinfo124 1个亿UFO...
# terryinfo123 <= terryinfo123::transfer {"from":"eosio","to":"terryinfo124","quantity":"100000000.0000 UFO","memo":"terryinfo123 to terryinf...
# eosio <= terryinfo123::transfer {"from":"eosio","to":"terryinfo124","quantity":"100000000.0000 UFO","memo":"terryinfo123 to terryinf...
# terryinfo124 <= terryinfo123::transfer {"from":"eosio","to":"terryinfo124","quantity":"100000000.0000 UFO","memo":"terryinfo123 to terryinf...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#12、查询当前账户代币余额
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos get currency balance terryinfo123 terryinfo124 UFO
#查询结果:
100000000.0000 UFO
#13、代币转账给普通用户
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos push action terryinfo123 transfer '["terryinfo124","terryinfo125","1000.0000 UFO","terryinfo124 to terryinfo125 1000 UFOT"]' -p terryinfo124
#成功提示:
executed transaction: 8d42a7bd19a86fcb9dbd672fa485ef6a9514c23acd65c09a0c95248e0c5a1129 168 bytes 948 us
# terryinfo123 <= terryinfo123::transfer {"from":"terryinfo124","to":"terryinfo125","quantity":"1000.0000 UFO","memo":"terryinfo124 to terryi...
# terryinfo124 <= terryinfo123::transfer {"from":"terryinfo124","to":"terryinfo125","quantity":"1000.0000 UFO","memo":"terryinfo124 to terryi...
# terryinfo125 <= terryinfo123::transfer {"from":"terryinfo124","to":"terryinfo125","quantity":"1000.0000 UFO","memo":"terryinfo124 to terryi...
warning: transaction executed locally, but may not be confirmed by the network yet ]
#13.1查询当前代币账户余额:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos get currency balance terryinfo123 terryinfo124 UFO
99999000.0000 UFO
#13.2查询terryinfo125账户余额:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos get currency balance terryinfo123 terryinfo125 UFO
1000.0000 UFO
#注意:如果在执行上诉任意命令时提示如下错误,请参考如下:
#1、需要解锁
Error 3120003: Locked wallet
Ensure that your wallet is unlocked before using it!
#解锁命令:
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet unlock -n terrywallet --password PW5JfV9vXC6oARtpmAh7sghUefoMzKCGBBE7XaZB3jm6e7PRfFEAT
#成功提示:
Unlocked: terrywallet
#2、需要导入EOSIO密钥
Error 3090003: Provided keys, permissions, and delays do not satisfy declared authorizations
Ensure that you have the related private keys inside your wallet and your wallet is unlocked.
#导入EOSIO密钥命令:EOSIO账户密钥查询在 ~/.local/share/eosio/nodeos/config/config.ini配置文件中
terry@terry-VirtualBox:~/eos/build/programs/cleos$ ./cleos wallet import --private-key 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3 -n terrywallet
#成功提示:
imported private key for: EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV