Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

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

4645979
148 0 0
先决条件
0 M, r& x% ^4 X/ SDocker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。  z( ^5 K+ v% s1 J( I. j
1.获取镜像
. B' W4 f9 G/ f0 |" N7 H  a+ ~EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。, m; F2 n9 R: v, @" O
从存储库中提取镜像:$ U) _; S9 ^+ x+ r0 |" Z
docker pull eosio/eos-dev
; U. e+ f* M% d7 D# Y7 w! D
1 K- e( Z! b' _8 D! t7 k3 X' E开启EOSIO节点1 G% m3 n/ \, D$ H
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"2 ^, {1 Q! ?- [2 t) M# P) `
检查它的工作情况:
2 y" U3 P4 u! Ddocker logs --tail 10 eosio" q0 K3 h2 k5 M, P( g( [$ a3 o
输出应该类似这样:$ u% @* j# D, l, z$ R9 ?: ~: R2 g
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]
9 @, S' w; f) x1929502ms 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]/ u! U- Z, w3 Y" [$ D, `, Z
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]$ y9 J+ r: Z) y
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]  p4 ^; m1 e. K1 d4 Q& ?% j* q2 B
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]
5 c8 F$ h. `9 K6 e( ]6 v1931501ms 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]+ M$ y3 N  A0 f$ X+ }1 T1 j, X
1932001ms 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]+ Q5 R& I# F, E+ M& F
1932501ms 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], i1 Y. s7 b/ V0 t
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]
  F4 n; l; Z: S! W, u1933501ms 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]
* \; d" I" t; r2 |1 H恭喜!你有一个非常简单的单节点区块链运行在你的docker中!
7 `' ?. F3 o# ~" d' U' n也可以通过浏览器中的这个地址来检查RPC接口是否工作:
* t# A- V! M8 j+ U  whttp://localhost:8888/v1/chain/get_info
! v+ [6 }. j; u, u你应该看到类似的信息:* v. ?5 ~1 c, a0 B% t
{, l* a( Z. v( N: H
    "server_version": "0961a560",7 k' C6 A. G+ b+ ~; j/ f
    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
# \; u% m/ T7 r' I- V    "head_block_num": 13780,7 \% r! y, j; t" W* c& A
    "last_irreversible_block_num": 13779,
2 M* p. s2 w- x    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",0 r) `+ `! v3 R, {
    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",- x6 ~; m. S2 p" C4 j$ e
    "head_block_time": "2018-05-23T16:30:54",6 N  D8 {+ p+ j1 g
    "head_block_producer": "eosio",  g8 V+ E% M2 U4 L+ s/ X' d7 E
    "virtual_block_cpu_limit": 100000000,
- d7 _0 M+ B+ x/ B+ T4 F2 t# i7 M    "virtual_block_net_limit": 1048576000,
, _, b6 V6 [, P" m8 c% Z2 g2 ]    "block_cpu_limit": 99900,
- K# S- O  }$ U$ b    "block_net_limit": 1048576* j" T8 y* i$ f+ w: [8 V9 }: i; O7 c& h
}: U. @' W& s2 g7 J5 ^" t
2.Cleos别名7 E. p0 b  K+ D) f5 e" \% _
cleos是一个命令行接口,负责与区块链交互并管理钱包。
" N+ a4 \' E) ~为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:
/ U; Z  r  F. B' k- o- p+ b5 w5 ealias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'! s& x. C7 v" I  z! H( B/ W
3.确认是否安装成功  q' `, O( }. v& i; ]+ x
现在试着在你的终端中运行cleos --help。你应该看到一个输出:
$ Q  y! O1 F0 S: Q6 }9 q4 FCommand Line Interface to EOSIO Client8 q' b% W: O7 Q# Q: j! `/ z2 ]
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND( P$ w7 ]* Q4 c
Options:& s) _2 F0 ^( H; A/ o
  -h,--help                   Print this help message and exit& g5 N/ P9 m6 j! s! E# O0 D1 a
  -u,--url TEXT=http://localhost:8888/0 ^, w7 _# C3 A' n. N
                              the http/https URL where nodeos is running( ^: O0 B, h: y. E  B% L7 I" p5 ^
  --wallet-url TEXT=http://localhost:8900/
- k- U# E3 Q) ?$ B                              the http/https URL where keosd is running
( I* P, m$ v4 R8 B0 U  X$ z: l  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers) n* b6 a" {7 E% D* B* |- q
  -n,--no-verify              don't verify peer certificate when using HTTPS& l0 c' G; r- t
  -v,--verbose                output verbose actions on error. O7 b8 S$ X2 F" ?* ]
Subcommands:! p* N, k; o0 W7 N& j! [
  version                     Retrieve version information' q4 W  }- n! D" Y$ [; n7 `
  create                      Create various items, on and off the blockchain
( s% t9 K- L3 S; F+ |! N  get                         Retrieve various items and information from the blockchain
3 i* i& Z- Y$ S5 U: Z- r$ n  set                         Set or update blockchain state
0 ?( f! o' n* Z+ k& F; N  transfer                    Transfer EOS from account to account
6 @% z& A: B& Z7 S  net                         Interact with local p2p network connections7 O/ F0 ?4 B( s; i3 ]' v8 ^
  wallet                      Interact with local wallet, v1 T  C  L- I' S$ Y
  sign                        Sign a transaction
' B! t2 H. T. s# D5 O  push                        Push arbitrary transactions to the blockchain2 `1 L/ B) t# y, |2 p% B7 {9 ~6 U
  multisig                    Multisig contract commands
# @, K; M8 a; R  system                      Send eosio.system contract action to the blockchain.6 f; v; a# d* c( N$ b
令人惊叹的!我们跑起来了。
5 j' u/ J) n+ W+ Z停止EOSIO容器
: V! I( G1 v, D* V. z" F% q当需要停止时,请使用:
( h8 z* B4 R2 y* Lbash docker stop eosio/ w8 b" i( N1 {7 E$ ]: l3 {+ _  [
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:4 ~, a" T: W: n; K" K2 G
EOS教程. a4 v1 d- d7 K' M( f
本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
! a0 m4 h- f, Q) B' x原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1