私链eosio.system合约部署
放弃六月们
发表于 2022-11-10 08:55:48
156
0
0
eos版本:v1.0.5$ E' _$ v5 ?: O( R0 \8 P
操作系统:centos 7
环境:私有链
目的
由于正式链的ram,net带宽,cpu带宽太宝贵,对于测试的同学建议先在私链上进行测试,避免浪费EOS币。9 c& x' E. W' Q- I
部署
部署是以私有链并且没有创建任何账号和合约为例,如果已经创建账号和部署智能合约,请对号入座跳着看。% M+ _3 n4 w: q# @9 ?4 b
6 ~, d1 T' B. I" a
//重复1,2创建必备账号$ x! Z0 ]& P4 Z- G/ N3 M8 u9 l$ {
//eosio.token6 Y* F2 G& V8 e$ \
//eosio.system
//eosio.ram2 F6 o0 M* }1 w' e0 m
//eosio.ramfee
//eosio.stake
//默认在代码根目录下执行
//1.创建密钥对
cleos create key7 M' I0 X! b+ k* ?% _
Private key: 5KKibeZ9KX2bR3MZQnTRVx5aGgpGqtsuitkr21FkpwRERuRk4Ym8 D& D" B' _; V+ ?' m% D
Public key: EOS7d1YqzyP52FBkfmyu5pLVPpKjWZ4Ld3DZg8997eFLLZWLb7QUL
//2.创建账号
cleos create account eosio eosio.token ${publicKey} ${publicKey}! I; Z' ]6 c$ l
//部署eosio.token,发布代币
cleos set contract eosio.token ../../contracts/eosio.token/
cleos push action eosio.token create '["eosio","1000000000.0000 EOS",0,0,0]' -p eosio.token+ V& f" F, B, u" e6 t5 ~# Z- h1 g2 F
cleos push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio6 Q5 n( p7 R+ `; C% Z
//部署eosio.system,报错如下,要保证开头注明的四个账号已经创建; R* W. F9 K9 e: [0 i C2 R+ }) c
cleos set contract eosio ../../contracts/eosio.system/ -p eosio
Reading WAST/WASM from ../../contracts/eosio.system/eosio.system.wasm...' p$ b7 C2 ~6 y7 @- d5 G6 r
Using already assembled WASM...
Publishing contract...
Error 3080006: transaction took too long i9 y2 n3 y+ D) v( K
//注意0 e N0 Z0 p/ A. t6 C: R8 z- L
./eosio_build.sh -s "EOS" 购买资源的币种,要使用默认的币种,不写则为SYS
//创建交易账号
cleos system newaccount --stake-net "10.0000 SYS" --stake-cpu "10.0000 SYS" --buy-ram-kbytes 3 eosio eosiotest EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
//查看账号信息,输出资源信息则为部署成功9 M8 p, \" G, z/ P [* n
cleos get account eosiotest
permissions: . N2 l/ X: d! p
owner 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
active 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
memory:
quota: 2.973 KiB used: 2.926 KiB . x9 z2 d; G! e: c5 p; ~- y& B
net bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)7 e4 H9 I, @2 D7 g' p. D. n3 o: x
used: 0 bytes
available: 8.145 TiB
limit: 8.145 TiB
cpu bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)
used: 0 us 2 L1 E8 u9 x y0 ], {9 @+ E
available: 473.5 hr 1 t' ?7 h( a" K, U4 j2 {, c
limit: 473.5 hr3 B" w* {# P' [0 q2 h: ? _
" U$ P3 K4 @3 R0 K' b: z1 ?+ e' K
//给账号转账
cleos push action eosio.token transfer '["eosio","eosiotest","100.0000 SYS",""]' -p eosio7 I, w! E: S( V9 C. N1 r% u
//再将eosiotest转账到eosio,验证资源是否减少
cleos push action eosio.token transfer '["eosiotest","eosio","100.0000 SYS",""]' -p eosio
//再次查看账号信息,发现资源变少- x. `! D; G+ O2 z5 F( c$ {
cleos get account eosiotest0 S) [% `5 d. [
问题汇总
Q:部署合约报错:unable to find key) Z! {; r$ i5 K& T
A:4.0以后默认系统币名字是SYS,所以需要发布的代币修改成SYS,或者修改eosio_build.sh脚本中默认名称,重新进行编译(参考下图)- {) F8 X! e R5 y1 z4 `
& G3 ]+ a% X3 C
Q:transaction took too long
A:nodeos程序启动时添加max-transaction-time或者修改config.ini对应属性,重新启动nodeos
Q:to account does not exist" p: l7 @7 E I) G
A:在部署system合约之前,必须创建三个账号eosio.ram,eosio.ramfee,eosio.stake
成为第一个吐槽的人