Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

通过docker快速安装构建EOSIO开发环境

4645979
92 0 0
先决条件
  |- z; s" t) _4 x; @" V9 A+ zDocker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。; ]1 d4 k# _/ k0 m, d8 u6 h6 k3 k
1.获取镜像
, ^( y5 K  x  Z/ ]EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。& O2 ]& ^& Z& S- G6 ]
从存储库中提取镜像:
+ S5 u  D7 P/ j* }" W0 _6 \/ adocker pull eosio/eos-dev
- x1 [7 K5 ~+ A  O
# P7 s* E* [" h9 z" t0 m开启EOSIO节点" h: Q; N' ?# U) q. N7 `: i
docker run --rm --name eosio -d -p 8888:8888 -p 9876:9876 -v /tmp/work:/work -v /tmp/eosio/data:/mnt/dev/data -v /tmp/eosio/config:/mnt/dev/config eosio/eos-dev  /bin/bash -c "nodeos -e -p eosio --plugin eosio::wallet_api_plugin --plugin eosio::wallet_plugin --plugin eosio::producer_plugin --plugin eosio::history_plugin --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin --plugin eosio::http_plugin -d /mnt/dev/data --config-dir /mnt/dev/config --http-server-address=0.0.0.0:8888 --access-control-allow-origin=* --contracts-console --http-validate-host=false"& q; n& V; |; ]; B& A* D
检查它的工作情况:
8 z" x8 {. T8 `8 M, @' ]6 D/ f* Wdocker logs --tail 10 eosio3 F6 @$ n3 X2 Z* Q6 D7 f, `  V7 R
输出应该类似这样:
! u2 _& O( p0 k! p* q$ v9 K1929001ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366974ce4e2a... #13929 @ 2018-05-23T16:32:09.000 signed by eosio [trxs: 0, lib: 13928, confirmed: 0]
; f7 B2 P1 \1 A6 }4 G/ p1929502ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366aea085023... #13930 @ 2018-05-23T16:32:09.500 signed by eosio [trxs: 0, lib: 13929, confirmed: 0]
2 C, L. U2 H9 H/ K6 M3 |1930002ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366b7f074fdd... #13931 @ 2018-05-23T16:32:10.000 signed by eosio [trxs: 0, lib: 13930, confirmed: 0]1 {, l& `! ?* H% h' b
1930501ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366cd8222adb... #13932 @ 2018-05-23T16:32:10.500 signed by eosio [trxs: 0, lib: 13931, confirmed: 0]
" f/ U1 E: }" P- a5 F+ O- u1931002ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366d5c1ec38d... #13933 @ 2018-05-23T16:32:11.000 signed by eosio [trxs: 0, lib: 13932, confirmed: 0]
9 @5 A2 B7 {$ q* Y0 g1931501ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366e45c1f235... #13934 @ 2018-05-23T16:32:11.500 signed by eosio [trxs: 0, lib: 13933, confirmed: 0]
0 L# g& {4 R3 }( H! t( K. z1932001ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000366f98adb324... #13935 @ 2018-05-23T16:32:12.000 signed by eosio [trxs: 0, lib: 13934, confirmed: 0]
+ t/ s/ e7 Q1 d1 a1932501ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 00003670a0f01daa... #13936 @ 2018-05-23T16:32:12.500 signed by eosio [trxs: 0, lib: 13935, confirmed: 0]: T4 K3 C& e" _8 L5 X
1933001ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 00003671e8b36e1e... #13937 @ 2018-05-23T16:32:13.000 signed by eosio [trxs: 0, lib: 13936, confirmed: 0]+ k' r0 g( ?  e& u* s. u
1933501ms thread-0   producer_plugin.cpp:585       block_production_loo ] Produced block 0000367257fe1623... #13938 @ 2018-05-23T16:32:13.500 signed by eosio [trxs: 0, lib: 13937, confirmed: 0]" x, ]" }' }1 }; B
恭喜!你有一个非常简单的单节点区块链运行在你的docker中!+ O. d( i- ]; J1 ~$ `* C
也可以通过浏览器中的这个地址来检查RPC接口是否工作:
) g) ~/ W2 x, f% E: ]http://localhost:8888/v1/chain/get_info
3 L/ u4 |; j" W9 v你应该看到类似的信息:0 _, S$ g+ o& U; H+ W
{7 f! R7 g6 W' u$ F/ d! X
    "server_version": "0961a560",7 y- W9 d+ H7 D$ T$ q
    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",/ V. H6 p3 }* b8 |2 J
    "head_block_num": 13780,% O" ]& W: f; b$ F1 M
    "last_irreversible_block_num": 13779,9 V- q' f6 |) U9 a
    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",' l" J. O: m+ V( k4 h4 m
    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
1 q8 z5 ?8 v  p3 N" h    "head_block_time": "2018-05-23T16:30:54",/ R  F1 {/ A& j+ r4 e
    "head_block_producer": "eosio",
. Q0 S' e; N  g' v, Q& n    "virtual_block_cpu_limit": 100000000,
- n  O; k1 \4 {, k& i, M+ H    "virtual_block_net_limit": 1048576000,# n" `; W* ~# V% z
    "block_cpu_limit": 99900,
/ t6 ~# W& l' f4 B8 C8 p3 x6 m    "block_net_limit": 1048576, I$ ^) g. H, s' L0 i8 S( E
}7 }% p% O8 H* z7 R9 ?  _
2.Cleos别名
- R* ]( j' k0 t+ q; i& Z7 Q! L, S* mcleos是一个命令行接口,负责与区块链交互并管理钱包。# c9 I9 I9 ^3 ]9 e/ x! a
为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:
; m- q) w1 A# O8 E$ p/ ^2 walias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'6 z; A4 M8 W0 d6 _
3.确认是否安装成功
2 f+ X( u3 h+ X: q- d" [6 _现在试着在你的终端中运行cleos --help。你应该看到一个输出:
1 \# g$ r; L0 R; C- K1 ^: aCommand Line Interface to EOSIO Client8 y. j! o% E# y6 [( M# E
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND& t& S" C2 z% X' e
Options:
, x/ D) i. [  D  -h,--help                   Print this help message and exit0 U' u5 a7 {+ P4 v+ D9 M
  -u,--url TEXT=http://localhost:8888/& m4 [( a& }3 E/ |0 I1 T, q# p
                              the http/https URL where nodeos is running
. a6 V" h( Q" C6 Q! x" B  --wallet-url TEXT=http://localhost:8900/
8 N) I( s/ u$ B7 B5 g! f/ c                              the http/https URL where keosd is running( b" U+ g2 s, z9 v, T
  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers: A: r0 W" a% o
  -n,--no-verify              don't verify peer certificate when using HTTPS5 |" A" Y& d# l# M- f4 R) d
  -v,--verbose                output verbose actions on error$ `6 s6 t5 r7 j+ M+ |( D0 O
Subcommands:
$ J7 f& [7 W! {- u9 n  version                     Retrieve version information
$ L4 O5 L( @- o3 F/ @0 v. o4 Q  create                      Create various items, on and off the blockchain4 S& {) m% A! x  D6 D9 V. ?: r4 A( c
  get                         Retrieve various items and information from the blockchain; L- G, y# p  X5 \# j5 I
  set                         Set or update blockchain state0 |" U2 t, M/ V" k- F5 R
  transfer                    Transfer EOS from account to account
" ]+ `1 R* x! v  net                         Interact with local p2p network connections0 r0 k- ^, q! a! A8 [
  wallet                      Interact with local wallet8 N: m; m- K5 }1 v
  sign                        Sign a transaction8 J( P& A/ V% C+ @6 j# a
  push                        Push arbitrary transactions to the blockchain) i; A$ M0 Q. V& D
  multisig                    Multisig contract commands
' B3 r' g+ {2 h* ?# ^8 V  system                      Send eosio.system contract action to the blockchain.
2 z+ K4 R" G: D( S令人惊叹的!我们跑起来了。
. l. }$ v7 p; H  [0 Q) F停止EOSIO容器6 p; t& P" \4 N/ U; ~
当需要停止时,请使用:
9 r3 U+ f) \$ ~7 n3 ]bash docker stop eosio* O8 W  N# a4 }: I" M9 O3 D1 Q
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:+ R0 h) q: q9 A/ ]$ W
EOS教程
1 p. z4 o5 |/ F7 X/ Q本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
% m0 S/ C- `% k0 D/ r原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1