【EOS智能合约】发行代币(二)

在执行以下操作前要保证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
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 213,186评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,858评论 3 387
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 158,620评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,888评论 1 285
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,009评论 6 385
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,149评论 1 291
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,204评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,956评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,385评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,698评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,863评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,544评论 4 335
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,185评论 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,899评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,141评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,684评论 2 362
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,750评论 2 351

推荐阅读更多精彩内容