iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 20
0
Blockchain

又LAG的EOS.IO技術筆記系列 第 20

[系統合約後續]建立開發測試帳號 (系統合約部署後)

  • 分享至 

  • xImage
  •  

昨日我一開始照以往部署合約時,有發生問題。處理辦法和原因以後再稍做說明。今天還是先來進入部署系統合約後的後續吧!

簡單看一下差異

在部署系統合約後,cleos裡有許多的命令算是可以正式啟用了。eosio.system是當中最主要的合約,他會依賴非常多東西,包含eosio.token。不過如果只是單純開發,可以只部署需要的合約,像是只部署eosio.token

在部署合約後,最主要的差異在於資源和帳號上,立馬來看一下吧!

無法在透過cleos create account建立帳號

cleos create account eos bob <PUBLIC KEY>

Output:

Error 3080001: Account using more than allotted RAM usage
Error Details:
account alice has insufficient ram; needs 2996 bytes has 0 bytes

在透過cleos create account來建立帳號會報錯。會需要改用下面方式建立帳號:

cleos system newaccount eosio alice <PUBLIC KEY> --stake-net '1000.000 SYS' --stake-cpu '100.000 SYS' --buy-ram '1000.000 SYS'

喔對,還沒發幣呢。上面SYS可不能用

cleos push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active
cleos push action eosio.token issue '[ "eosio", "1000000000.0000 SYS", "memo" ]' -p eosio@active

你會發現在cleos system newaccount會執行一堆Action

75554ec2caed404e4ae701aebeb4e16d0f402e089e413506cab82ba4cfb61826  344 bytes  1463 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"alice","owner":{"threshold":1,"keys":[{"key":"EOS7U6iSYm5KEet2ZbqEubQLEyt...
#         eosio <= eosio::buyram                {"payer":"eosio","receiver":"alice","quant":"1000.0000 SYS"}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"995.0000 SYS","memo":"buy ram"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"995.0000 SYS","memo":"buy ram"}
#     eosio.ram <= eosio.token::transfer        {"from":"eosio","to":"eosio.ram","quantity":"995.0000 SYS","memo":"buy ram"}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"5.0000 SYS","memo":"ram fee"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"5.0000 SYS","memo":"ram fee"}
#  eosio.ramfee <= eosio.token::transfer        {"from":"eosio","to":"eosio.ramfee","quantity":"5.0000 SYS","memo":"ram fee"}
#         eosio <= eosio::delegatebw            {"from":"eosio","receiver":"alice","stake_net_quantity":"1000.0000 SYS","stake_cpu_quantity":"100.00...
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"eosio.stake","quantity":"1100.0000 SYS","memo":"stake bandwidth"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"eosio.stake","quantity":"1100.0000 SYS","memo":"stake bandwidth"}
#   eosio.stake <= eosio.token::transfer        {"from":"eosio","to":"eosio.stake","quantity":"1100.0000 SYS","memo":"stake bandwidth"}

包含建立帳戶、購買轉讓資源等等活動。這一系列Action構成newaccount這個Transaction(交易)。在EOSIO的智能合約裡,一個合約活動(Action)是可以去呼叫其他活動,包含不同的合約,整個過程構成一次交易。

除了建立帳號過程不同,這個新建立的帳號也有些不同:

cleos get account alice

Output:

permissions: 
     owner     1:    1 <PUBLIC KEY>
        active     1:    1 <PUBLIC KEY>
memory: 
     quota:     65.14 MiB    used:     2.926 KiB  

net bandwidth: 
     delegated:    1000.0000 SYS           (total staked delegated to account from others)
     used:                 0 bytes
     available:        590.9 GiB  
     limit:            590.9 GiB  

cpu bandwidth:
     delegated:     100.0000 SYS           (total staked delegated to account from others)
     used:                 0 us   
     available:        33.57 hr   
     limit:            33.57 hr   

在各個資源的使用量被加以限制了。


上一篇
部署系統合約eosio.system
下一篇
發幣與轉帳
系列文
又LAG的EOS.IO技術筆記31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言