昨日我一開始照以往部署合約時,有發生問題。處理辦法和原因以後再稍做說明。今天還是先來進入部署系統合約後的後續吧!
在部署系統合約後,cleos
裡有許多的命令算是可以正式啟用了。eosio.system
是當中最主要的合約,他會依賴非常多東西,包含eosio.token
。不過如果只是單純開發,可以只部署需要的合約,像是只部署eosio.token
。
在部署合約後,最主要的差異在於資源和帳號上,立馬來看一下吧!
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
在各個資源的使用量被加以限制了。