Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

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

4645979
96 0 0
先决条件
9 E+ w4 d: s% w5 wDocker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。
3 G, V/ y6 J  z6 Z# {& v6 S4 e1.获取镜像
( y. ?; B' K9 z, w. ]( GEOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。; _% I6 E1 i, g! w9 y; A4 p
从存储库中提取镜像:: }' k; ~& [: ^
docker pull eosio/eos-dev
8 m! p+ b& N5 U' I' _+ L  B  w
/ a! T: R, j3 i2 v9 B# O开启EOSIO节点
' f  ^2 d: {6 y7 y) A+ Jdocker 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"
3 ]8 w7 n8 H4 X检查它的工作情况:' w) }& e9 G5 v  ^# }* y
docker logs --tail 10 eosio- e* D& S, J: t$ ]
输出应该类似这样:( T3 F* ?: E% D2 J
1929001ms 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]+ G# R  [5 b0 m7 p& ?, Q- T
1929502ms 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 `0 y0 D, W& ^! \4 W( P1930002ms 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]
/ G. ]; C7 r' n. [% z9 J2 K4 X1930501ms 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]7 Z0 A- s2 o3 O! O+ H. d% }
1931002ms 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]
& D4 L6 |8 N! X9 R1931501ms 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]
  L( q8 |# I4 G* ~6 X' G1932001ms 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]
  W  T+ @2 x9 Y3 Q9 l1932501ms 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]/ M2 m5 q& h4 j: l! b2 _1 u
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]- O1 A, X; K+ o2 d0 x, S3 Z! r
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]
4 i/ ]/ O, S8 G* M/ |# c恭喜!你有一个非常简单的单节点区块链运行在你的docker中!* p: \5 m3 |9 U  f5 r
也可以通过浏览器中的这个地址来检查RPC接口是否工作:" g! d; u9 |5 _
http://localhost:8888/v1/chain/get_info# b6 ?' Z# y9 ?% G1 p9 a) m
你应该看到类似的信息:
2 A6 `. L( W( j5 H{
& J6 z7 B9 T/ u) k    "server_version": "0961a560",
' P3 A- c, o. k6 {3 b; l6 u    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",, C& r- ?2 U3 Y1 x) C
    "head_block_num": 13780,
3 U/ g" t7 Z# ^  p3 E( k    "last_irreversible_block_num": 13779,
- p  z. ?& D: v8 C& P# I/ s    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",) s/ _% |, K- _4 W) X! f) H5 P
    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
% D% W; Q& j- _  \9 _+ d    "head_block_time": "2018-05-23T16:30:54",2 Z* I' b7 ?, x2 g7 x1 d4 Q
    "head_block_producer": "eosio",: o. H3 e; }% [4 H, t
    "virtual_block_cpu_limit": 100000000,# l& t9 \' e8 Q$ d
    "virtual_block_net_limit": 1048576000,
6 k/ c2 E" R+ h, [    "block_cpu_limit": 99900,3 g4 r3 r$ [. P6 k& h$ C& h
    "block_net_limit": 10485769 V% C* q0 F" T% i
}
# p% _' T1 V4 `, p7 n7 H( v& B- Q2.Cleos别名& T8 f* j) z' y$ O. v  z
cleos是一个命令行接口,负责与区块链交互并管理钱包。
1 K% A$ c: U" X! j为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:
2 z% I9 d5 O9 B* malias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'# z& ]# B; `3 I3 u% I
3.确认是否安装成功
2 K6 I* v1 g1 f现在试着在你的终端中运行cleos --help。你应该看到一个输出:2 ~0 ]. S7 _. T
Command Line Interface to EOSIO Client* y& O; f' e. l
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND- L! T, v0 Q* B" {! T
Options:
2 j- O& {% @$ J6 T* a1 }3 W  -h,--help                   Print this help message and exit' I& ^$ w" Y! r# e
  -u,--url TEXT=http://localhost:8888/! x6 g3 R' V; V( [: g
                              the http/https URL where nodeos is running
: n( @8 \. U. y/ L: ~) @$ d3 X  --wallet-url TEXT=http://localhost:8900/
# M7 w% r$ c/ a- B+ U2 j                              the http/https URL where keosd is running
  t/ g9 q' o1 Q5 S  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers
' E/ m( i' E* @8 E8 X) S2 {  -n,--no-verify              don't verify peer certificate when using HTTPS
2 |" B6 \3 b1 n5 d, d  -v,--verbose                output verbose actions on error5 s  F" y% c5 K4 Y6 b# f7 i
Subcommands:$ h8 |  a2 z' A8 d% g/ B$ ~" ~& g
  version                     Retrieve version information
' i  b  m+ D& n3 @$ \$ W  create                      Create various items, on and off the blockchain  f! l9 y* p6 D  a( ^6 n4 z
  get                         Retrieve various items and information from the blockchain; O$ t8 ?2 i  W) _* R$ K
  set                         Set or update blockchain state
4 W4 @. S5 o3 m5 ^  D  transfer                    Transfer EOS from account to account& s, [7 N/ p+ O' k0 V, K9 ?. x
  net                         Interact with local p2p network connections  t" w4 _. b/ J. B! T! W" P8 P; D
  wallet                      Interact with local wallet
3 C/ J; \$ v1 X2 s* J) H  sign                        Sign a transaction9 [7 E. O# _) P/ n/ g
  push                        Push arbitrary transactions to the blockchain2 W6 R0 V. |0 ]+ N% G
  multisig                    Multisig contract commands
/ G* }  l" P* X0 U  system                      Send eosio.system contract action to the blockchain.
; V* Z$ p' M  W9 D令人惊叹的!我们跑起来了。& S! h% h# m& r, x0 E- Y' e
停止EOSIO容器* b' J* L# W4 l9 o( d# Z
当需要停止时,请使用:
! |9 W* ~. E0 g" J: [1 `2 Sbash docker stop eosio( G8 ~: C$ h; }% [9 m: d
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:
% c( K/ D* V2 y! e8 hEOS教程
" d6 ?; i. v, V) j本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。4 E' o% Z; N. |- @, P- f
原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1