前言
上一篇中已经使用第三方节点连接到了测试网,现在,这篇文章主要是关于在测试网创建账号,发布代币,以及关于一些转账手续费的讲解。
生成两组公私钥对,创建账户的时候需要使用:
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos create key --to-console
Private key: 5JQqYxDETU7nzaUnRaYgqD4LZpsHER8TGbAD4U7ov5uhFAEpLqH
Public key: EOS5DbBzK6kTW1JZPMKKYUzTK63iyrBz3qAgSnbfURt9Qw5nk82vN
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos create key --to-console
Private key: 5JrKtVMVxxRQxoERZPxVNtGtm3ug2JwGiA8QFwZDFvEb81KXhtq
Public key: EOS8iXKzxDF6GD7Q8V9GCQfPKEyT9aCSVMFiF9ZkGZnn85m2gie7L
1.创建账户
之前通过http://jungle.cryptolions.io的Create account选项创建的账户nettest11111,
现在,使用cleos,通过nettest11111来创建新的账户
测试和主网中,创建账户需要为新账号购买和抵押一定的资源;
--stake-net:抵押的网络带宽资源,单位为EOS
--stake-cpu:抵押的CPU带宽资源,单位为EOS
--buy-ram-kbytes:购买的内存资源,单位为KB
--buy-ram:购买的内存资源,单位为EOS
创建账户
注意:之前在本地用的是create account,使用之后发现有错误,通过查看cleos的文档https://developers.eos.io/eosio-cleos/reference#cleos-create-account,发现在生产环境中,创建账号需要使用cleos system newaccount(https://developers.eos.io/eosio-cleos/reference#cleos-system-newaccount)命令替代。
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u "http://dev.cryptolions.io:38888" system newaccount --stake-net '10 EOS' --stake-cpu '10 EOS' --buy-ram-kbytes 10 nettest11111 nettests1111 EOS8iXKzxDF6GD7Q8V9GCQfPKEyT9aCSVMFiF9ZkGZnn85m2gie7L EOS8iXKzxDF6GD7Q8V9GCQfPKEyT9aCSVMFiF9ZkGZnn85m2gie7L
创建成功,来查询一下新账户nettests1111的情况:
cleos -u http://dev.cryptolions.io:38888 get account nettests1111
我们刚才创建了新账户nettests1111,并为其购买了11的RAM,NET和CPU各抵押了10个eos。
再来查看一下nettest11111的账户情况
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 get account nettest11111
之前这个账户有100个EOS的可用余额。现在还有 79.2126个EOS可用余额,刚刚创建账号大约花了20.7874EOS
我们来看看花费的详情:
--各抵押了10EOS的NET和CPU,总共20EOS
--购买10kb的RAM,花费了0.7834个EOS,可以从创建账号的返回情况看到
{"from":"nettest11111","to":"eosio.ram","quantity":"0.7834 EOS","memo":"buy ram"}
--购买RAM时,系统收取了0.0040 EOS个交易费
{"from":"nettest11111","to":"eosio.ramfee","quantity":"0.0040 EOS","memo":"ram fee"}
总共:20+0.7834+0.0040=20.7874
刚好相同
在对比创建nettest11111和nettests1111两个账号时,发现两个账号信息有个地方明显不同
nettest11111的网络资源和CPU都为staked 100EOS,而delegated 0 EOS,nettests1111正好相反,
staked 0EOS,delegated 100 EOS
原因
nettest11111的NET和CPU都是此账号自己抵押的,如果申请赎回,那么这200EOS将会退给nettest11111;
nettests1111的NET和CPU都是由nettest11111抵押的,nettests1111无法申请赎回,只能由nettest11111
申请赎回,这200EOS将会退给nettest11111
2.转账
给创建好的nettests1111账号转点EOS
再次查看nettests1111信息,
cleos -u http://dev.cryptolions.io:38888 get account nettests1111
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 get account nettests1111
created: 2018-11-27T05:58:55.500
permissions:
owner 1: 1 EOS8iXKzxDF6GD7Q8V9GCQfPKEyT9aCSVMFiF9ZkGZnn85m2gie7L
active 1: 1 EOS8iXKzxDF6GD7Q8V9GCQfPKEyT9aCSVMFiF9ZkGZnn85m2gie7L
memory:
quota: 11.32 KiB used: 2.926 KiB
net bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 1.824 MiB
limit: 1.824 MiB
cpu bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)
used: 0 us
available: 363.8 ms
limit: 363.8 ms
EOS balances:
liquid: 10.0000 EOS
staked: 0.0000 EOS
unstaking: 0.0000 EOS
total: 10.0000 EOS
3.创建、发行、转账代币
前几篇文章已经详细将结果代币的创建、发行和转账了EOS学习笔记(四)部署-发布-转账。
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 set contract nettest11111 ./build/contracts/eosio.token -p nettest11111@active
Reading WASM from ./build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
Error 3080001: Account using more than allotted RAM usage
Error Details:
account nettest11111 has insufficient ram; needs 194213 bytes has 5474 bytes
查看错误信息,发现部署代币合约需要194kb的内存,当前只有54kb,为nettest11111在购买一些内存
cleos -u http://dev.cryptolions.io:38888 system buyram nettest11111 nettest11111 "60.0000 EOS"
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 system buyram nettest11111 nettest11111 "60.0000 EOS"
executed transaction: 11d671a43137c7e64604e260f92ab152f4c4026b96d410a6dcfbc41445f89cbd 128 bytes 837 us
# eosio <= eosio::buyram {"payer":"nettest11111","receiver":"nettest11111","quant":"60.0000 EOS"}
# eosio.token <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ram","quantity":"59.7000 EOS","memo":"buy ram"}
# nettest11111 <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ram","quantity":"59.7000 EOS","memo":"buy ram"}
# eosio.ram <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ram","quantity":"59.7000 EOS","memo":"buy ram"}
# eosio.token <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ramfee","quantity":"0.3000 EOS","memo":"ram fee"}
# nettest11111 <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ramfee","quantity":"0.3000 EOS","memo":"ram fee"}
# eosio.ramfee <= eosio.token::transfer {"from":"nettest11111","to":"eosio.ramfee","quantity":"0.3000 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
可以看到系统扣除了0.5%的交易费,实际上只购买了59.7EOS
重新部署:
cleos -u http://dev.cryptolions.io:38888 set contract nettest11111
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 set contract nettest11111 ./build/contracts/eosio.token -p nettest11111@active
Reading WASM from ./build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: edbfc40be4560e042965c31bc486fe87465e95f4a81ed544cbf16216e22538e0 8104 bytes 1211 us
# eosio <= eosio::setcode {"account":"nettest11111","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7...
# eosio <= eosio::setabi {"account":"nettest11111","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6...
warning: transaction executed locally, but may not be confirmed by the network yet ]
创建代币
cleos -u http://dev.cryptolions.io:38888 push action nettest11111 create '{"issuer":"nettest11111", "maximum_supply": "100000000.0000 EOS", "can_freeze": 0, "can_recall": 0, "can_whitelist": 0}' -p nettest11111@active
can_freeze,can_recall和can_whitelist为布尔值,表示这个代币是否可以被发行人冻结,收回,或者白名单
发行代币
指定的发行人为nettest11111,将所有的代币都发行给了nettest11111
cleos -u http://dev.cryptolions.io:38888 push action nettest11111 issue '[ "nettest11111", "100000000.0000 EOS", "issue" ]' -p nettest11111
执行成功
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 push action nettest11111 issue '[ "nettest11111", "100000000.0000 EOS", "issue" ]' -p nettest11111
executed transaction: 67ce46cca6669fe852feca5153f65d2015c3df73733775ee2a5896c9f350502b 128 bytes 821 us
# nettest11111 <= nettest11111::issue {"to":"nettest11111","quantity":"100000000.0000 EOS","memo":"issue"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
查看余额:
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 get currency balance nettest11111 nettest11111
100000000.0000 EOS
nettest11111账户里面已经有了所有的EOS,转一些给nettests1111账户
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 push action nettest11111 transfer '[ "nettest11111", "nettests1111", "100.0000 EOS", "transfer to hs" ]' -p nettest11111
executed transaction: b3aa4badf0ed30ce91987191f3222e82a91c9f2222a22bf883e09b7c9c70762f 144 bytes 565 us
# nettest11111 <= nettest11111::transfer {"from":"nettest11111","to":"nettests1111","quantity":"100.0000 EOS","memo":"transfer to hs"}
# nettests1111 <= nettest11111::transfer {"from":"nettest11111","to":"nettests1111","quantity":"100.0000 EOS","memo":"transfer to hs"}
warning: transaction executed locally, but may not be confirmed by the network yet ]
此时查看一下,双方的代币余额:
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 get currency balance nettest11111 nettest11111
99999900.0000 EOS
xiaohulu@xiaohulu-virtual-machine:~/eos$ cleos -u http://dev.cryptolions.io:38888 get currency balance nettest11111 nettests1111
100.0000 EOS
网友评论