前言
上一篇中已經使用第三方節(jié)點連接到了測試網(wǎng)族铆,現(xiàn)在岩四,這篇文章主要是關于在測試網(wǎng)創(chuàng)建賬號,發(fā)布代幣哥攘,以及關于一些轉賬手續(xù)費的講解剖煌。
生成兩組公私鑰對,創(chuàng)建賬戶的時候需要使用:
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.創(chuàng)建賬戶
之前通過http://jungle.cryptolions.io的Create account選項創(chuàng)建的賬戶nettest11111逝淹,
現(xiàn)在耕姊,使用cleos,通過nettest11111來創(chuàng)建新的賬戶
測試和主網(wǎng)中栅葡,創(chuàng)建賬戶需要為新賬號購買和抵押一定的資源茉兰;
--stake-net:抵押的網(wǎng)絡帶寬資源,單位為EOS
--stake-cpu:抵押的CPU帶寬資源妥畏,單位為EOS
--buy-ram-kbytes:購買的內存資源邦邦,單位為KB
--buy-ram:購買的內存資源安吁,單位為EOS
? 創(chuàng)建賬戶
? 注意:之前在本地用的是create account,使用之后發(fā)現(xiàn)有錯誤,通過查看cleos的文檔https://developers.eos.io/eosio-cleos/reference#cleos-create-account燃辖,發(fā)現(xiàn)在生產環(huán)境中鬼店,創(chuàng)建賬號需要使用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
創(chuàng)建成功黔龟,來查詢一下新賬戶nettests1111的情況:
cleos -u http://dev.cryptolions.io:38888 get account nettests1111
我們剛才創(chuàng)建了新賬戶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的可用余額∥±猓現(xiàn)在還有 79.2126個EOS可用余額,剛剛創(chuàng)建賬號大約花了20.7874EOS
我們來看看花費的詳情:
--各抵押了10EOS的NET和CPU蛋欣,總共20EOS
--購買10kb的RAM航徙,花費了0.7834個EOS,可以從創(chuàng)建賬號的返回情況看到
{"from":"nettest11111","to":"eosio.ram","quantity":"0.7834 EOS","memo":"buy ram"}
--購買RAM時陷虎,系統(tǒng)收取了0.0040 EOS個交易費?
{"from":"nettest11111","to":"eosio.ramfee","quantity":"0.0040 EOS","memo":"ram fee"}
總共:20+0.7834+0.0040=20.7874
剛好相同
在對比創(chuàng)建nettest11111和nettests1111兩個賬號時到踏,發(fā)現(xiàn)兩個賬號信息有個地方明顯不同
nettest11111的網(wǎng)絡資源和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.轉賬
? ? 給創(chuàng)建好的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.創(chuàng)建、發(fā)行惨恭、轉賬代幣
? 前幾篇文章已經詳細將結果代幣的創(chuàng)建秉馏、發(fā)行和轉賬了EOS學習筆記(四)部署-發(fā)布-轉賬。
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
? ? 查看錯誤信息脱羡,發(fā)現(xiàn)部署代幣合約需要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? ? ? ? ]
可以看到系統(tǒng)扣除了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? ? ? ? ]
創(chuàng)建代幣
?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為布爾值,表示這個代幣是否可以被發(fā)行人凍結脓规,收回栽连,或者白名單
發(fā)行代幣
指定的發(fā)行人為nettest11111,將所有的代幣都發(fā)行給了nettest11111
cleos -u? http://dev.cryptolions.io:38888 push action nettest11111? issue '[ "nettest11111", "100000000.0000 EOS", "issue" ]' -p nettest11111
?執(zhí)行成功
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