EOS開發(fā)(轉(zhuǎn)載)使用cleos通過連接第三方節(jié)點(diǎn)宝冕,在主網(wǎng)/測試網(wǎng)創(chuàng)建賬戶和發(fā)幣代幣

1.前言

在上一篇文章中张遭,我們已經(jīng)通過連接第三方節(jié)點(diǎn)的方式加入到了主網(wǎng)或者測試網(wǎng)絡(luò)。這篇文章主要是關(guān)于在主網(wǎng)/測試網(wǎng)創(chuàng)建賬號(hào)地梨,發(fā)布代幣菊卷,以及關(guān)于一些轉(zhuǎn)賬手續(xù)費(fèi)的講解。

2.測試網(wǎng)絡(luò)

2.1 準(zhǔn)備工作

生成兩組公私鑰對宝剖,創(chuàng)建賬戶的時(shí)候需要:

yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Kbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Hrxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E

2.2 創(chuàng)建賬戶

之前洁闰,我們是通過http://jungle.cryptolions.ioCreate account選項(xiàng)創(chuàng)建的賬戶testnetyy111。這里我們使用cleos万细,通過testnetyy111來創(chuàng)建一個(gè)新的賬戶扑眉。

在主網(wǎng)和測試網(wǎng)絡(luò)中,創(chuàng)建賬號(hào)不像之前本地私鏈那樣可以隨意創(chuàng)建雅镊,而是需要為新賬戶購買和抵押一定的資源襟雷,使得新賬號(hào)可以進(jìn)行一定的操作刃滓,例如轉(zhuǎn)賬等仁烹。需要購買的資源是RAM,需要抵押的資源是NETCPU咧虎。創(chuàng)建賬號(hào)時(shí)卓缰,使用以下參數(shù)指定要購買和抵押的資源數(shù)量:

  • --stake-net:抵押的網(wǎng)絡(luò)帶寬資源,單位為EOS

  • --stake-cpu:抵押的CPU帶寬資源砰诵,單位為EOS

  • --buy-ram-kbytes:購買的內(nèi)存資源征唬,單位為KB

  • --buy-ram:購買的內(nèi)存資源,單位為EOS

創(chuàng)建賬戶:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "http://jungle.cryptolions.io:18888" create account --stake-net '100 EOS' --stake-cpu '100 EOS' --buy-ram-kbytes 1000 testnetyy111 testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
ERROR: ExtrasError: [--stake-net --stake-cpu --buy-ram-kbytes testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E]
Create an account, buy ram, stake for bandwidth for the account
Usage: cleos create account [OPTIONS] creator name OwnerKey [ActiveKey]

Positionals:
  creator TEXT                The name of the account creating the new account (required)
  name TEXT                   The name of the new account (required)
  OwnerKey TEXT               The owner public key for the new account (required)
  ActiveKey TEXT              The active public key for the new account

Options:
  -h,--help                   Print this help message and exit
  -x,--expiration             set the time in seconds before a transaction expires, defaults to 30s
  -f,--force-unique           force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times
  -s,--skip-sign              Specify if unlocked wallet keys should be used to sign transaction
  -j,--json                   print result as json
  -d,--dont-broadcast         don't broadcast transaction to the network (just print to stdout)
  --return-packed             used in conjunction with --dont-broadcast to get the packed transaction
  -r,--ref-block TEXT         set the reference block num or block id used for TAPOS (Transaction as Proof-of-Stake)
  -p,--permission TEXT ...    An account and permission level to authorize, as in 'account@permission'
  --max-cpu-usage-ms UINT     set an upper limit on the milliseconds of cpu usage budget, for the execution of the transaction (defaults to 0 which means no limit)
  --max-net-usage UINT        set an upper limit on the net usage budget, in bytes, for the transaction (defaults to 0 which means no limit)

發(fā)現(xiàn)報(bào)錯(cuò)了茁彭。通過查看cleos的文檔https://developers.eos.io/eosio-cleos/reference#cleos-create-account总寒,發(fā)現(xiàn)在生產(chǎn)環(huán)境中,創(chuàng)建賬號(hào)需要使用cleos system newaccount(https://developers.eos.io/eosio-cleos/reference#cleos-system-newaccount)命令替代理肺。

再來:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "http://jungle.cryptolions.io:18888" system newaccount --stake-net '100 EOS' --stake-cpu '100 EOS' --buy-ram-kbytes 1000 testnetyy111 testneths111 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
executed transaction: 28cbc19117ec5c09edd90da7e25b1e742c5a954f7d0a1b2c88be91eceb4b5880  336 bytes  9736 us
#         eosio <= eosio::newaccount            {"creator":"testnetyy111","name":"testneths111","owner":{"threshold":1,"keys":[{"key":"EOS7RkP6aevKj...
#         eosio <= eosio::buyrambytes           {"payer":"testnetyy111","receiver":"testneths111","bytes":1024000}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}
#         eosio <= eosio::delegatebw            {"from":"testnetyy111","receiver":"testneths111","stake_net_quantity":"100.0000 EOS","stake_cpu_quan...
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
#   eosio.stake <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.stake","quantity":"200.0000 EOS","memo":"stake bandwidth"}
2018-09-05T06:09:44.828 thread-0   main.cpp:455                  print_result   warning: transaction executed locally, but may not be confirmed by the network yet

成功摄闸!我們查詢下新賬戶testneths111的情況:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testneths111
permissions: 
     owner     1:    1 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
        active     1:    1 EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
memory: 
     quota:     994.9 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        3.661 sec  
     limit:            3.661 sec  

我們剛才創(chuàng)建了新賬戶testneths111,并為其購買了1000kbRAM妹萨,NETCPU各抵押了100個(gè)eos年枕。

再查查testnetyy111的賬戶情況:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     170.8 KiB    used:     3.646 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               337 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             9.041 ms   
     available:        3.652 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9741.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9941.6587 EOS

producers:     <not voted>

之前這個(gè)賬號(hào)有10000eos的可用余額,現(xiàn)在剩余9741.6587eos的可用余額乎完,剛才創(chuàng)建賬號(hào)花費(fèi)了大約258.3413eos熏兄,我們來看看花費(fèi)明細(xì):

  • 各抵押了100eos的NETCPU,總共200eos

  • 購買了1000kb的RAM,花費(fèi)58.0495eos摩桶∏抛矗可以從創(chuàng)建賬號(hào)時(shí)的返回日記查看:

#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"58.0495 EOS","memo":"buy ram"}

  • 購買RAM時(shí),系統(tǒng)收取了0.2918eos的RAM交易手續(xù)費(fèi)硝清〉夯拢可以從創(chuàng)建賬號(hào)時(shí)的返回日記查看:
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.2918 EOS","memo":"ram fee"}

合計(jì):

200 + 58.0495 + 0.2918 = 258.3413

正好吻合

staked和delegated

這里注意看下這兩個(gè)賬號(hào)的信息。testnetyy111的網(wǎng)絡(luò)資源和CPU資源都為staked 100 eos耍缴,而delegated 0 eos砾肺。testneths111的網(wǎng)絡(luò)資源和CPU資源都為delegated 100 eos,而沒有staked選項(xiàng)防嗡。

這表示的是变汪,testnetyy111的網(wǎng)絡(luò)資源和CPU資源都是此賬號(hào)自己抵押的,如果申請贖回蚁趁,那這200 eos將會(huì)退給testnetyy111裙盾。

testneths111的網(wǎng)絡(luò)資源和CPU資源都是由testnetyy111抵押的。testneths111無法申請贖回他嫡,只能由testnetyy111申請贖回番官,并且這200 eos將會(huì)退給testnetyy111而不是testneths111

2.3 EOS轉(zhuǎn)賬

給新賬戶轉(zhuǎn)點(diǎn)EOS:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 transfer testnetyy111 testneths111 "100 EOS" "hi there"
executed transaction: a2a4d081bf5af18c3f74a3fecb0dd9c65db1490aaeeee00433c9a9a2b83868bc  136 bytes  1540 us
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
#  testneths111 <= eosio.token::transfer        {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 EOS","memo":"hi there"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

查看testneths111賬戶信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testneths111
permissions: 
     owner     1:    1 EOS7RkP6aevKjN1CiKSqo44Gi1HhPYBczGFgSduBXBD7uHUFhg2qC
        active     1:    1 EOS7sGb8DfutGgpuMmnDhG1d2stVETfpkrHQ6HhVRJJaPXRqLay2E
memory: 
     quota:     994.9 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     delegated:     100.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        3.661 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:          100.0000 EOS
     staked:            0.0000 EOS
     unstaking:         0.0000 EOS
     total:           100.0000 EOS

已經(jīng)有100eos的余額了

也可以使用下面的方法獲取余額:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance eosio.token testnetyy111
9641.6587 EOS
10000.0000 JUNGLE
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance eosio.token testneths111
100.0000 EOS

JUNGLE是由于testnetyy111賬戶是通過Jungle Testnet網(wǎng)頁創(chuàng)建的钢属,所以默認(rèn)還給了10000JUNGLE代幣

2.4 轉(zhuǎn)賬手續(xù)費(fèi)

我們再來查看下testnetyy111賬戶的情況:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     170.8 KiB    used:     3.881 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               455 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             10.13 ms   
     available:        3.651 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9641.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9841.6587 EOS

producers:     <not voted>

對比下轉(zhuǎn)賬前RAM徘熔、NET、CPU的使用情況:

  • RAM:轉(zhuǎn)賬前3.646 KiB used淆党,轉(zhuǎn)賬后3.881 KiB used

  • NET:轉(zhuǎn)賬前337 bytes used酷师,轉(zhuǎn)賬后455 bytes used

  • CPU:轉(zhuǎn)賬前9.041 ms used,轉(zhuǎn)賬后10.13 ms used

可以看到染乌,轉(zhuǎn)賬后testnetyy111各項(xiàng)資源的使用都增加了山孔。轉(zhuǎn)賬需要消耗使用EOS抵押的網(wǎng)絡(luò)和CPU資源,并且需要將testneths111持有了EOS的信息記錄到內(nèi)存上荷憋。雖然網(wǎng)絡(luò)和CPU資源會(huì)由系統(tǒng)定期自動(dòng)釋放台颠,也就是恢復(fù),并且可以贖回成EOS勒庄,但是內(nèi)存是使用EOS購買的串前,雖然可以賣出,但是系統(tǒng)不會(huì)定期釋放锅铅。所以第一次向沒有EOS代幣的testneths111賬戶轉(zhuǎn)賬多少會(huì)有一些(因?yàn)槭褂昧藘?nèi)存的)手續(xù)費(fèi)酪呻。

為什么說只有第一次轉(zhuǎn)賬EOS沒有手續(xù)費(fèi)呢?因?yàn)榻?jīng)過后續(xù)實(shí)驗(yàn)盐须,如果testnetyy111再給testneths111轉(zhuǎn)賬EOS玩荠,testnetyy111的內(nèi)存消耗并不會(huì)增加。原因是,首先阶冈,之前內(nèi)存上已經(jīng)記錄了testneths111持有EOS的信息闷尿,轉(zhuǎn)賬不會(huì)再次記錄。其次女坑,雖然轉(zhuǎn)賬方testnetyy111的網(wǎng)絡(luò)和CPU消耗再次增加填具,但是由于兩者的恢復(fù)機(jī)制,消耗的網(wǎng)絡(luò)和CPU會(huì)再次恢復(fù)匆骗。所以此時(shí)實(shí)現(xiàn)了真正意義上的轉(zhuǎn)賬無手續(xù)費(fèi)劳景。

我們繼續(xù)試驗(yàn)。將testneths111的私鑰導(dǎo)入testnet.wallet錢包碉就,然后將所有EOS轉(zhuǎn)回給testnetyy111盟广。然后再次查看testnetyy111的賬戶,這時(shí)可以發(fā)現(xiàn)瓮钥,testnetyy111的內(nèi)存使用降低了筋量。原因是testneths111不再持有EOS,所以系統(tǒng)刪除了testneths111持有EOS的這條記錄碉熄,并將之前的記錄此信息的內(nèi)存退回給了testnetyy111桨武。

2.5 創(chuàng)建、發(fā)行锈津、轉(zhuǎn)賬代幣

之前的文章已經(jīng)詳細(xì)講解過代幣的創(chuàng)建呀酸、發(fā)行和轉(zhuǎn)賬了,這里不再詳細(xì)說明了

testnetyy111賬戶部署代幣合約:

uyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 set contract testnetyy111 ../../../build/contracts/eosio.token -p testnetyy111@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 testnetyy111 has insufficient ram; needs 194060 bytes has 174927 bytes

查看報(bào)錯(cuò)信息一姿,發(fā)現(xiàn)部署代幣合約需要194kb的內(nèi)存七咧,當(dāng)前只有174kb。我們?yōu)?code>testnetyy111再購買些內(nèi)存:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 system buyram testnetyy111 testnetyy111 "100 EOS"
executed transaction: 695beb8644042b44b10dcf2028964996c864f9804d7df5182f32ddda92ff8fd4  128 bytes  5017 us
#         eosio <= eosio::buyram                {"payer":"testnetyy111","receiver":"testnetyy111","quant":"100.0000 EOS"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ram","quantity":"99.5000 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
#  testnetyy111 <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"testnetyy111","to":"eosio.ramfee","quantity":"0.5000 EOS","memo":"ram fee"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

買了100eos的內(nèi)存叮叹,實(shí)際只買到了99.5eos的內(nèi)存,因?yàn)楸幌到y(tǒng)扣了%0.5的交易手續(xù)費(fèi)爆存◎韧纾看下現(xiàn)在有多少內(nèi)存了:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get account testnetyy111
permissions: 
     owner     1:    1 EOS6cnhSLTn4eSUEqS4nC8frYTsVsjeH2M3hos1TUeCgme2Yim5Q5
        active     1:    1 EOS6Z7mUQeFC2cQTT3xMyZh2wsLQoHih1bTMgRhr3dbichprTi7Rc
memory: 
     quota:     1.831 MiB    used:     3.881 KiB  

net bandwidth: 
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:               549 bytes
     available:        18.32 MiB  
     limit:            18.32 MiB  

cpu bandwidth:
     staked:        100.0000 EOS           (total stake delegated from account to self)
     delegated:       0.0000 EOS           (total staked delegated to account from others)
     used:             12.96 ms   
     available:        3.648 sec  
     limit:            3.661 sec  

EOS balances: 
     liquid:         9541.6587 EOS
     staked:          200.0000 EOS
     unstaking:         0.0000 EOS
     total:          9741.6587 EOS

producers:     <not voted>

足夠了。我們重新部署代幣合約:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 set contract testnetyy111 ../../../build/contracts/eosio.token -p testnetyy111@active
Reading WASM from ../../../build/contracts/eosio.token/eosio.token.wasm...
Publishing contract...
executed transaction: 7cff6eac58075d3bc12c0479b8bf420f36b7ec2c136a832a007efa48cea57591  8112 bytes  3438 us
#         eosio <= eosio::setcode               {"account":"testnetyy111","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7...
#         eosio <= eosio::setabi                {"account":"testnetyy111","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d6...
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

查看一下testnetyy111的賬戶情況先较,剛才部署代幣合約使用了大約186kb的內(nèi)存携冤。

完整的創(chuàng)建代幣的命令:

cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 create '{"issuer":"testnetyy111", "maximum_supply": "100000000.0000 RAY", "can_freeze": 0, "can_recall": 0, "can_whitelist": 0}' -p testnetyy111@active

can_freezecan_recallcan_whitelist為布爾值闲勺,表示這個(gè)代幣是否可以被發(fā)行人凍結(jié)曾棕,收回,或者白名單菜循。

我們可以也使用更簡略的命令創(chuàng)建代幣:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 create '[ "testnetyy111", "100000000.0000 RAY", 0, 0, 0]' -p testnetyy111
executed transaction: dfc45b660f42beca5bb0a6dbe081d1d37b4931d004a59bac0801304db6a84ffb  120 bytes  765 us
#  testnetyy111 <= testnetyy111::create         {"issuer":"testnetyy111","maximum_supply":"100000000.0000 RAY"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

我們指定的發(fā)行人為testnetyy111∏痰兀現(xiàn)在將全部代幣都發(fā)行給testnetyy111

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 issue '[ "testnetyy111", "100000000.0000 RAY", "issue" ]' -p testnetyy111
executed transaction: b0c71715e9dc3284513d6fc29e4c2fc130ff2a54eb621cc472cdc037c63a1124  128 bytes  1303 us
#  testnetyy111 <= testnetyy111::issue          {"to":"testnetyy111","quantity":"100000000.0000 RAY","memo":"issue"}
warning: transaction executed locally, but may not be confirmed by the network yet    ]

查看下余額:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testnetyy111
100000000.0000 RAY

現(xiàn)在testnetyy111賬戶中已經(jīng)有100000000.0000 RAY,我們轉(zhuǎn)點(diǎn)代幣給testneths111

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 push action testnetyy111 transfer '[ "testnetyy111", "testneths111", "100.0000 RAY", "transfer to hs" ]' -p testnetyy111
executed transaction: cc2dd7d3a52f753cf139c4076cfecaa61e4cb853fc91ec9490e26cdaa4052513  144 bytes  1489 us
#  testnetyy111 <= testnetyy111::transfer       {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 RAY","memo":"transfer to hs"}
#  testneths111 <= testnetyy111::transfer       {"from":"testnetyy111","to":"testneths111","quantity":"100.0000 RAY","memo":"transfer to hs"}
warning: transaction executed locally, but may not be confirmed by the network yet    ]

查看下雙方的代幣余額:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testnetyy111
99999900.0000 RAY
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u http://jungle.cryptolions.io:18888 get currency balance testnetyy111 testneths111
100.0000 RAY

沒毛病

3. 主網(wǎng)

3.1 準(zhǔn)備工作

主網(wǎng)的流程和測試網(wǎng)絡(luò)基本一樣

創(chuàng)建一個(gè)錢包,管理主網(wǎng)的私鑰

創(chuàng)建一個(gè)名為mainnet.wallet的錢包

yuyangdeMacBook-Pro:cleos yuyang$ cleos wallet create -n mainnet --to-console
Creating wallet: mainnet
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

將我之前在主網(wǎng)申請的賬戶yuyangray222的私鑰導(dǎo)入錢包

yuyangdeMacBook-Pro:cleos yuyang$ cleos wallet import --private-key 5JLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -n mainnet
imported private key for: EOS69mwiYuMhfWtwLVXxaXfao7YXF2Kh39nZurdDw6RF1ntQy6DnW

生成兩個(gè)私鑰衙耕,創(chuàng)建賬戶的時(shí)候需要:

yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5Jwhxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
yuyangdeMacBook-Pro:cleos yuyang$ cleos create key --to-console
Private key: 5JdJxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Public key: EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG

3.2 創(chuàng)建賬戶

先確認(rèn)下是否連接的是主網(wǎng):

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get info
{
  "server_version": "e87d245d",
  "chain_id": "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906",
  "head_block_num": 14959813,
  "last_irreversible_block_num": 14959477,
  "last_irreversible_block_id": "00e443756eed3ed6a238b63cf87897b069ec84ffb82adceffc3ae0a9469e0b16",
  "head_block_id": "00e444c5fec4a19e4b524c4d84140edb18106b5562cd22d7d7b34fdc90fc1e15",
  "head_block_time": "2018-09-06T03:24:17.500",
  "head_block_producer": "libertyblock",
  "virtual_block_cpu_limit": 200000000,
  "virtual_block_net_limit": 1048576000,
  "block_cpu_limit": 197819,
  "block_net_limit": 1048432,
  "server_version_string": "v1.2.3-dirty"
}

使用yuyangray222創(chuàng)建一個(gè)新賬戶huashangtech

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" system newaccount --stake-net '1 EOS' --stake-cpu '1 EOS' --buy-ram-kbytes 20 yuyangray222 huashangtech EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
executed transaction: e10f0e02c963c7b49e939c82ca34917b5607e8925e685d6b48bed27ea372e0a7  336 bytes  5765 us
#         eosio <= eosio::newaccount            {"creator":"yuyangray222","name":"huashangtech","owner":{"threshold":1,"keys":[{"key":"EOS66griGzoa9...
#         eosio <= eosio::buyrambytes           {"payer":"yuyangray222","receiver":"huashangtech","bytes":20480}
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ram","quantity":"2.2453 EOS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.ramfee","quantity":"0.0113 EOS","memo":"ram fee"}
#         eosio <= eosio::delegatebw            {"from":"yuyangray222","receiver":"huashangtech","stake_net_quantity":"1.0000 EOS","stake_cpu_quanti...
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
#   eosio.stake <= eosio.token::transfer        {"from":"yuyangray222","to":"eosio.stake","quantity":"2.0000 EOS","memo":"stake bandwidth"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

抵押了1eosNET1eosCPU昧穿,購買了20K的內(nèi)存

查看新賬戶huashangtech信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get account huashangtech
permissions: 
     owner     1:    1 EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
        active     1:    1 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
memory: 
     quota:     21.27 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        668.9 KiB  
     limit:            668.9 KiB  

cpu bandwidth:
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        126.1 ms   
     limit:            126.1 ms   

3.3 EOS轉(zhuǎn)賬

yuyangray222轉(zhuǎn)一個(gè)EOS給huashangtech

cleos -u "https://api.eosnewyork.io" transfer yuyangray222 huashangtech "1 EOS" "hi huashangtech"
yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" transfer yuyangray222 huashangtech "1 EOS" "hi huashangtech"
executed transaction: d8fd505b3bbce4416ee390587f758a804218d1057657f189013a62107d6f64a4  144 bytes  1206 us
#   eosio.token <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
#  yuyangray222 <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
#  huashangtech <= eosio.token::transfer        {"from":"yuyangray222","to":"huashangtech","quantity":"1.0000 EOS","memo":"hi huashangtech"}
warning: transaction executed locally, but may not be confirmed by the network yet    ] 

再次查看huashangtech賬戶信息:

yuyangdeMacBook-Pro:cleos yuyang$ cleos -u "https://api.eosnewyork.io" get account huashangtech
permissions: 
     owner     1:    1 EOS66griGzoa99n2mjGacBKEndMFAACrmJi7zn1xJ6jieDv4K1SB9
        active     1:    1 EOS6x1ZXjAJLrHy67hCdM13ue2t4BCvNp55qMcqtvyfPULFQAAtRG
memory: 
     quota:     21.27 KiB    used:     2.926 KiB  

net bandwidth: 
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        668.9 KiB  
     limit:            668.9 KiB  

cpu bandwidth:
     delegated:       1.0000 EOS           (total staked delegated to account from others)
     used:                 0 us   
     available:        126.1 ms   
     limit:            126.1 ms   

EOS balances: 
     liquid:            1.0000 EOS
     staked:            0.0000 EOS
     unstaking:         0.0000 EOS
     total:             1.0000 EOS

余額已有1EOS

3.4 創(chuàng)建、發(fā)行橙喘、轉(zhuǎn)賬代幣

由于在主網(wǎng)部署代幣合約至少需要賬戶內(nèi)有200k的內(nèi)存时鸵,以現(xiàn)在內(nèi)存的價(jià)格,大概需要23個(gè)EOS以上厅瞎,后面有機(jī)會(huì)再補(bǔ)充饰潜,不過流程都和在測試網(wǎng)上基本一致。

作者:yuyangray
鏈接:http://www.reibang.com/p/a5d631043822
來源:簡書
簡書著作權(quán)歸作者所有和簸,任何形式的轉(zhuǎn)載都請聯(lián)系作者獲得授權(quán)并注明出處囊拜。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市比搭,隨后出現(xiàn)的幾起案子冠跷,更是在濱河造成了極大的恐慌,老刑警劉巖身诺,帶你破解...
    沈念sama閱讀 212,718評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件蜜托,死亡現(xiàn)場離奇詭異,居然都是意外死亡霉赡,警方通過查閱死者的電腦和手機(jī)橄务,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評論 3 385
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來穴亏,“玉大人蜂挪,你說我怎么就攤上這事∩せ” “怎么了棠涮?”我有些...
    開封第一講書人閱讀 158,207評論 0 348
  • 文/不壞的土叔 我叫張陵,是天一觀的道長刺覆。 經(jīng)常有香客問我严肪,道長,這世上最難降的妖魔是什么谦屑? 我笑而不...
    開封第一講書人閱讀 56,755評論 1 284
  • 正文 為了忘掉前任驳糯,我火速辦了婚禮,結(jié)果婚禮上氢橙,老公的妹妹穿的比我還像新娘酝枢。我一直安慰自己,他們只是感情好悍手,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,862評論 6 386
  • 文/花漫 我一把揭開白布帘睦。 她就那樣靜靜地躺著袍患,像睡著了一般。 火紅的嫁衣襯著肌膚如雪官脓。 梳的紋絲不亂的頭發(fā)上协怒,一...
    開封第一講書人閱讀 50,050評論 1 291
  • 那天,我揣著相機(jī)與錄音卑笨,去河邊找鬼孕暇。 笑死,一個(gè)胖子當(dāng)著我的面吹牛赤兴,可吹牛的內(nèi)容都是我干的妖滔。 我是一名探鬼主播,決...
    沈念sama閱讀 39,136評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼桶良,長吁一口氣:“原來是場噩夢啊……” “哼座舍!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起陨帆,我...
    開封第一講書人閱讀 37,882評論 0 268
  • 序言:老撾萬榮一對情侶失蹤曲秉,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后疲牵,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體承二,經(jīng)...
    沈念sama閱讀 44,330評論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,651評論 2 327
  • 正文 我和宋清朗相戀三年纲爸,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了亥鸠。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,789評論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡识啦,死狀恐怖负蚊,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情颓哮,我是刑警寧澤家妆,帶...
    沈念sama閱讀 34,477評論 4 333
  • 正文 年R本政府宣布,位于F島的核電站题翻,受9級(jí)特大地震影響揩徊,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜嵌赠,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,135評論 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望熄赡。 院中可真熱鬧姜挺,春花似錦、人聲如沸彼硫。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,864評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至词渤,卻和暖如春牵舱,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背缺虐。 一陣腳步聲響...
    開封第一講書人閱讀 32,099評論 1 267
  • 我被黑心中介騙來泰國打工芜壁, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人高氮。 一個(gè)月前我還...
    沈念sama閱讀 46,598評論 2 362
  • 正文 我出身青樓慧妄,卻偏偏與公主長得像,于是被迫代替她去往敵國和親剪芍。 傳聞我的和親對象是個(gè)殘疾皇子塞淹,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,697評論 2 351

推薦閱讀更多精彩內(nèi)容