私链eosio.system合约部署
放弃六月们
发表于 2022-11-10 08:55:48
114
0
0
eos版本:v1.0.5& f% X n a$ } j2 i1 @1 t$ R
操作系统:centos 7
环境:私有链
目的
由于正式链的ram,net带宽,cpu带宽太宝贵,对于测试的同学建议先在私链上进行测试,避免浪费EOS币。2 E; u( ]. g$ q7 Q" b7 i
部署* B4 x" j7 @, D, E5 F
部署是以私有链并且没有创建任何账号和合约为例,如果已经创建账号和部署智能合约,请对号入座跳着看。/ ]/ S! ^. ?- o* ~+ S) w# I. A
" `# _; T3 g$ E+ n( d9 t- v4 u
//重复1,2创建必备账号3 {2 N) G" e6 ~, s
//eosio.token
//eosio.system
//eosio.ram
//eosio.ramfee
//eosio.stake$ v7 f6 s* h* X+ M: U* j& U" x
//默认在代码根目录下执行# q/ y" f( r5 K% S( M& U
//1.创建密钥对
cleos create key' r1 V% {* @* I) u7 ]
Private key: 5KKibeZ9KX2bR3MZQnTRVx5aGgpGqtsuitkr21FkpwRERuRk4Ym
Public key: EOS7d1YqzyP52FBkfmyu5pLVPpKjWZ4Ld3DZg8997eFLLZWLb7QUL
//2.创建账号! m% b/ K/ B6 q& s5 `, J
cleos create account eosio eosio.token ${publicKey} ${publicKey}' l/ _6 J' Q5 V: ~0 w/ A$ q. R9 @& q
//部署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.token7 y$ v# B8 u3 S
cleos push action eosio.token issue '["eosio","1000000000.0000 EOS","issue"]' -p eosio# e- ^# T5 p- F8 r; X( d" W0 o
//部署eosio.system,报错如下,要保证开头注明的四个账号已经创建3 b+ o; q+ F. i0 r% t
cleos set contract eosio ../../contracts/eosio.system/ -p eosio6 o ]5 z: {+ P: P0 E% k: }
Reading WAST/WASM from ../../contracts/eosio.system/eosio.system.wasm...- F7 e. K. z4 Z8 S# O$ y
Using already assembled WASM...4 W8 ]6 J) M; a; T. O- s& I
Publishing contract...
Error 3080006: transaction took too long9 J& C& W9 y/ M0 \% `9 f
//注意
./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
//查看账号信息,输出资源信息则为部署成功! m5 t( a$ [ b$ h z2 R
cleos get account eosiotest
permissions:
owner 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV
active 1: 1 EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV* ]+ [0 j- @; m' ^: m
memory:
quota: 2.973 KiB used: 2.926 KiB # J- @/ Z" F8 k' ^. q. Z
net bandwidth: 4 ]7 E# `" t. S$ o
delegated: 10.0000 EOS (total staked delegated to account from others)
used: 0 bytes
available: 8.145 TiB 5 E( X0 Q# `3 M6 R7 u3 ]
limit: 8.145 TiB . N( u; |2 a a+ q
cpu bandwidth:
delegated: 10.0000 EOS (total staked delegated to account from others)& ]6 s5 U1 P6 p: {. e, R
used: 0 us
available: 473.5 hr 8 ?6 ^$ |/ O" ]
limit: 473.5 hr
//给账号转账
cleos push action eosio.token transfer '["eosio","eosiotest","100.0000 SYS",""]' -p eosio
//再将eosiotest转账到eosio,验证资源是否减少* M( i4 p+ ~) u
cleos push action eosio.token transfer '["eosiotest","eosio","100.0000 SYS",""]' -p eosio6 W3 g! \ S* }9 J2 f! c
//再次查看账号信息,发现资源变少# N; ?: l% [ F' _. k3 q4 s3 l H
cleos get account eosiotest
问题汇总
Q:部署合约报错:unable to find key
A:4.0以后默认系统币名字是SYS,所以需要发布的代币修改成SYS,或者修改eosio_build.sh脚本中默认名称,重新进行编译(参考下图)
0 c- j* t5 ^$ i6 w' x# r
Q:transaction took too long6 g$ q9 b! J% ^8 e& T) z
A:nodeos程序启动时添加max-transaction-time或者修改config.ini对应属性,重新启动nodeos
Q:to account does not exist" r3 d6 c9 L, G- `
A:在部署system合约之前,必须创建三个账号eosio.ram,eosio.ramfee,eosio.stake
成为第一个吐槽的人