私链eosio.system合约部署
放弃六月们
发表于 2022-11-10 08:55:48
104
0
0
eos版本:v1.0.5+ j! v7 x* n+ e
操作系统:centos 7
环境:私有链
目的
由于正式链的ram,net带宽,cpu带宽太宝贵,对于测试的同学建议先在私链上进行测试,避免浪费EOS币。6 }& i: G/ |3 a
部署. O3 l; I" B g/ A# R( d$ B
部署是以私有链并且没有创建任何账号和合约为例,如果已经创建账号和部署智能合约,请对号入座跳着看。
//重复1,2创建必备账号
//eosio.token
//eosio.system
//eosio.ram/ `; Q9 X: l8 f/ F+ F
//eosio.ramfee
//eosio.stake/ N; E. r9 R4 r8 S% _2 S& p1 F9 `
//默认在代码根目录下执行
//1.创建密钥对
cleos create key8 ~! o8 X0 a' V9 D
Private key: 5KKibeZ9KX2bR3MZQnTRVx5aGgpGqtsuitkr21FkpwRERuRk4Ym
Public key: EOS7d1YqzyP52FBkfmyu5pLVPpKjWZ4Ld3DZg8997eFLLZWLb7QUL
//2.创建账号
cleos create account eosio eosio.token ${publicKey} ${publicKey} p' j+ D% }+ M: \& x
//部署eosio.token,发布代币
cleos set contract eosio.token ../../contracts/eosio.token/1 c5 O* W3 \# s8 E, v5 C
cleos push action eosio.token create '["eosio","1000000000.0000 EOS",0,0,0]' -p eosio.token8 ]! g7 ?! h) r/ U' ~" i
cleos push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio3 \* A1 o+ B: R1 [ k2 l) V: m( W2 T: C
//部署eosio.system,报错如下,要保证开头注明的四个账号已经创建
cleos set contract eosio ../../contracts/eosio.system/ -p eosio
Reading WAST/WASM from ../../contracts/eosio.system/eosio.system.wasm...1 u; y) w9 S6 ^! N" P6 d
Using already assembled WASM...
Publishing contract...
Error 3080006: transaction took too long
//注意/ }' Z' L( }0 W+ D# Y) t
./eosio_build.sh -s "EOS" 购买资源的币种,要使用默认的币种,不写则为SYS% x4 S+ R0 T# g; }6 }9 ^9 D/ s
//创建交易账号
cleos system newaccount --stake-net "10.0000 SYS" --stake-cpu "10.0000 SYS" --buy-ram-kbytes 3 eosio eosiotest EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
//查看账号信息,输出资源信息则为部署成功0 F* E; d- u, D2 T* l
cleos get account eosiotest
permissions:
owner 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
active 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV+ R! Q: l$ O& P0 ~& N# e+ X
memory: " V( @) f5 v% ?) J" c" V
quota: 2.973 KiB used: 2.926 KiB 0 ^9 P0 e7 M9 Q4 Y) n) e- t9 H
net bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)# l2 L8 H9 Q# r4 S
used: 0 bytes! q7 I3 f) j0 j
available: 8.145 TiB
limit: 8.145 TiB
cpu bandwidth:5 ?; W9 L4 H6 C0 \1 y- ]
delegated: 10.0000 EOS (total staked delegated to account from others)
used: 0 us 8 U- {; h" H' K* F
available: 473.5 hr . r% }4 d" z% A- Q: b4 f. F6 u
limit: 473.5 hr8 S% j: l5 ], \# ]' O1 J8 {
: w; a& g% i4 ?$ b" k: F0 L
//给账号转账
cleos push action eosio.token transfer '["eosio","eosiotest","100.0000 SYS",""]' -p eosio
//再将eosiotest转账到eosio,验证资源是否减少
cleos push action eosio.token transfer '["eosiotest","eosio","100.0000 SYS",""]' -p eosio; {3 |- ~3 Z; k+ [- s
//再次查看账号信息,发现资源变少
cleos get account eosiotest6 T1 ]2 R% b5 N4 A- S
问题汇总
Q:部署合约报错:unable to find key
A:4.0以后默认系统币名字是SYS,所以需要发布的代币修改成SYS,或者修改eosio_build.sh脚本中默认名称,重新进行编译(参考下图)
Q:transaction took too long
A:nodeos程序启动时添加max-transaction-time或者修改config.ini对应属性,重新启动nodeos
Q:to account does not exist4 r L7 \0 e# f' V
A:在部署system合约之前,必须创建三个账号eosio.ram,eosio.ramfee,eosio.stake
成为第一个吐槽的人