Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

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

4645979
158 0 0
先决条件' }3 d& w# T: n. ]& M* W
Docker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。1 r) ~7 i7 a. s, i
1.获取镜像
; n( h  R8 P$ w. j+ D5 C0 h+ [EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。
3 @& a; @# Y  n) ^) ~  `从存储库中提取镜像:9 x; V/ g1 N+ V( p
docker pull eosio/eos-dev
( B& {2 ]3 n' F. F' o' f0 M3 f$ i' x; ?) D/ @# u6 I) j6 W; Y# Y
开启EOSIO节点
2 k6 q0 w& k9 W) s2 Z% u! o9 ldocker 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"
8 L7 A, X& v: a5 Y检查它的工作情况:* J1 @7 l) e  J! \0 a
docker logs --tail 10 eosio
9 S. C  _3 Q% E" }2 y0 O* n输出应该类似这样:
: A. z; q- Q5 B1 O2 ~7 n1 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]9 a' m5 k% o( n
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]
4 p& p" l$ ^) w8 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]% z- s) f* f* B  w2 K- G, v/ e5 f% X( m
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]
0 v% y3 S# ^  O# g/ j1931002ms 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]0 a* s) c* J- _% o& ^+ U; ?
1931501ms 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]
2 ?; V! j  D8 L( a% U1932001ms 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]; s/ Q' P. z8 ~3 j- R
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]& O1 F$ K2 b  y5 }# o+ V
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]
* M4 Y$ c; Y9 n6 {9 @' e" C" a1933501ms 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]
; @9 r' y' W  J7 e4 K0 H. w恭喜!你有一个非常简单的单节点区块链运行在你的docker中!5 |7 K8 R: ~& }- A2 ~& ~) n
也可以通过浏览器中的这个地址来检查RPC接口是否工作:
* |- q- T1 ?4 `. t" bhttp://localhost:8888/v1/chain/get_info
0 J6 U5 D2 m' o  x/ f你应该看到类似的信息:
& B( t- V9 `% V2 v{
: K% y  M$ d: J, c# {9 t    "server_version": "0961a560",
+ S3 y$ R) O# k& m6 u9 p8 Q$ w    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
, Z+ v# r3 q+ a$ x* `1 o7 [: A    "head_block_num": 13780,* m7 N6 Y' u0 q3 k' ~, u
    "last_irreversible_block_num": 13779,& T/ w# {8 a, F  e6 j3 ?
    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",
, A1 d! a' K0 Z    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
* Y5 m- l# s9 y0 ?3 ]) K    "head_block_time": "2018-05-23T16:30:54",
+ [2 B3 U8 \9 Y6 L" [. f7 y. Q# D    "head_block_producer": "eosio",
$ g! h& k4 E! |    "virtual_block_cpu_limit": 100000000,2 S4 S: m& E" E2 }  z" j
    "virtual_block_net_limit": 1048576000,
0 o# M  w- Z& V& x1 k    "block_cpu_limit": 99900,: K" o! m/ n0 C5 _8 ~
    "block_net_limit": 10485767 n6 _% P1 c0 L7 ?# b, s
}
9 R' y, X2 o2 R7 b2.Cleos别名! M) I* ?: N0 f. F
cleos是一个命令行接口,负责与区块链交互并管理钱包。
/ N  {2 p6 {6 [: }( j4 i8 l为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:
% C7 Q8 M: I! y$ e/ Talias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'( Q5 I" x0 w) E. |# c  h# S0 _& b
3.确认是否安装成功5 {# r- ^! R, |) O9 ]# n' z
现在试着在你的终端中运行cleos --help。你应该看到一个输出:
6 Z+ h3 M' X8 |$ j1 I" ^Command Line Interface to EOSIO Client
( |4 V6 Q7 m* _+ P& {Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND, t! m# X8 y3 {
Options:
8 f; L8 @  A+ ^  -h,--help                   Print this help message and exit
( a; m' N0 B% l) ?' i  -u,--url TEXT=http://localhost:8888/: E0 L7 h" J. t- K9 d! S/ a
                              the http/https URL where nodeos is running
' l- u  y0 ?3 \  --wallet-url TEXT=http://localhost:8900/+ B7 G/ Q4 j5 i/ P
                              the http/https URL where keosd is running
( g1 K/ s+ m; F8 x& N  U+ A+ |  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers3 ^5 ^1 A' B* W8 q- T; S0 g8 P
  -n,--no-verify              don't verify peer certificate when using HTTPS) N/ S( T+ R- M( G3 q( K& X. o
  -v,--verbose                output verbose actions on error
6 B3 V9 V7 ]3 cSubcommands:5 K0 r8 d- ^% h) [9 o; H
  version                     Retrieve version information4 B" Q6 F6 n( ^$ F" m" e
  create                      Create various items, on and off the blockchain6 G0 T+ }# W2 Z4 O, s
  get                         Retrieve various items and information from the blockchain
5 @0 H2 U9 ?# Q% e! j  set                         Set or update blockchain state& M3 `, [6 V+ l; N+ v
  transfer                    Transfer EOS from account to account- u, x% q# ?4 ?+ s3 p3 \1 n
  net                         Interact with local p2p network connections, ?. ]( n5 t) H9 K: z9 d3 E% V
  wallet                      Interact with local wallet7 H0 v$ ^0 J+ ^! o- m5 v; Z
  sign                        Sign a transaction2 n$ a# \7 x4 \6 z. j
  push                        Push arbitrary transactions to the blockchain
$ b0 Z6 `, l1 J1 P2 e4 U  multisig                    Multisig contract commands
  l% Q$ t( i4 x) _% i% p# K  system                      Send eosio.system contract action to the blockchain.
% B) u3 f! m6 ^% ]! [; b- b令人惊叹的!我们跑起来了。$ v) n+ i2 Y9 m
停止EOSIO容器
; _; c5 q; v1 |! G1 }  G2 U- Q当需要停止时,请使用:, k* v: ]" v/ \& z
bash docker stop eosio
" @5 v$ d( K8 x0 `& f) _另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:
! L, k5 F, w% `) E8 \, TEOS教程
+ f; P9 U6 k& M. W, D8 Y+ L本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
" S$ i0 ^- U6 i: N  \原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1