Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

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

4645979
147 0 0
先决条件
' j/ l7 W$ H, NDocker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。% @4 i  V+ }' D' g& R+ t: I9 h' u. l! C
1.获取镜像: ]. l5 q  A# _
EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。
9 u$ b9 e* I  a& l0 U/ c从存储库中提取镜像:5 Z+ p5 ~; l' [0 i2 r' [  U! d
docker pull eosio/eos-dev
% f9 n8 }& ?+ l4 g. \
; h% E% j6 ]+ x( s# c7 Y0 ?# F2 `开启EOSIO节点
# N3 o9 z; m# ~2 P0 w% \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"
1 r7 E  h$ B+ M7 p, q检查它的工作情况:
& Y, |( Y4 z! [. A, y7 [docker logs --tail 10 eosio
1 o9 s6 i5 Z) J1 b1 w输出应该类似这样:
0 Z* a$ A( ]/ [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]0 n6 V% m5 {+ Q/ @3 {) x
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]
* J% s# O0 V  x1930002ms 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]6 J0 Q: o- w0 M* d
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]
7 G. B$ o2 f* b/ T" p$ k( A7 I1931002ms 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]
! Y% x. |) R' F9 O* |; b1931501ms 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]! N$ Z! s/ K* L2 O: b( i2 U) {
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]
/ ]5 Q. p) E& }( O- F1932501ms 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]# i+ e0 @' P3 _0 i5 z  K' y8 A
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]- j7 }/ c: K2 O, f
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]
+ ]7 @$ L, O1 r2 s6 n" Q恭喜!你有一个非常简单的单节点区块链运行在你的docker中!
1 b( p6 {/ x3 S" f1 J! Q% N也可以通过浏览器中的这个地址来检查RPC接口是否工作:
) l6 \  r# @4 |* J% O6 fhttp://localhost:8888/v1/chain/get_info3 i+ M! F9 ]: I% s  F& @
你应该看到类似的信息:) @1 }9 {* H5 |# q+ W
{
% a3 C6 M! ]7 T    "server_version": "0961a560",
) X! @+ g2 k4 E    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
- W( z, t! t: @" W( h+ v' o: a    "head_block_num": 13780,9 O. l* A! |5 x. g. j% A9 W
    "last_irreversible_block_num": 13779,
, E$ G8 x( p6 W3 |, H$ O    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",
3 W0 _. o8 ^; }: S7 F; M    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",: f; c- s3 v8 o
    "head_block_time": "2018-05-23T16:30:54",8 e5 R* h" A9 r( h3 h. h5 ^2 _
    "head_block_producer": "eosio",
2 y! P! H5 U5 n7 |% u+ ?( T, c; Z; t    "virtual_block_cpu_limit": 100000000,
% N; E* ]$ X3 k  P( V    "virtual_block_net_limit": 1048576000,& o' w" U# A* _8 D4 @" H
    "block_cpu_limit": 99900,7 Y+ h! e0 A2 F* V/ I( M
    "block_net_limit": 1048576# Z! _: _9 O2 ]2 Z. c) q2 J0 M
}7 T+ A9 V5 i/ O( P! L/ J3 p: d
2.Cleos别名3 [$ E& S' J7 h) e; }" C; u- P  x
cleos是一个命令行接口,负责与区块链交互并管理钱包。
/ t  U; a4 _1 ]# W# W  Y为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:) b3 l6 F% X8 W4 @
alias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'7 p1 [- L4 _% [( N( R+ s8 ~% }
3.确认是否安装成功
$ S  J! u; p9 e" e现在试着在你的终端中运行cleos --help。你应该看到一个输出:
. B; y" r* h4 R1 U3 xCommand Line Interface to EOSIO Client
+ w8 b1 ^% a: V7 D" }5 AUsage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND5 q8 h9 x& Y) _1 z) ?8 h+ ?
Options:
! x2 q& u; Z2 c* J  -h,--help                   Print this help message and exit
6 W8 e7 @! z+ Z9 D  -u,--url TEXT=http://localhost:8888/8 J. c  e" e6 F
                              the http/https URL where nodeos is running
) J- ^4 I0 t4 X. y' Y1 k# _/ w  --wallet-url TEXT=http://localhost:8900/5 l! y& h3 B7 T  S# T
                              the http/https URL where keosd is running
* b* t1 A3 l  T" v  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers# d1 B  m6 J) W, M" b
  -n,--no-verify              don't verify peer certificate when using HTTPS" w& X( j# l( p; _
  -v,--verbose                output verbose actions on error& k/ p% d! `* v: V5 @/ [- ?# J
Subcommands:6 Y; y; i3 P( p. X( f  v; X4 @
  version                     Retrieve version information
8 g* o0 }2 B5 f  create                      Create various items, on and off the blockchain
$ w4 g# ^! B0 u  get                         Retrieve various items and information from the blockchain
3 s# E4 j4 ]" V2 q  set                         Set or update blockchain state3 d' W. B$ g8 j' q- r
  transfer                    Transfer EOS from account to account& b( l. z/ l' t! t, g7 i- n
  net                         Interact with local p2p network connections! L4 p+ f2 v" e0 x
  wallet                      Interact with local wallet. W! c; \( }# l
  sign                        Sign a transaction: k, z! L( ~7 k' B; v
  push                        Push arbitrary transactions to the blockchain
: o6 ?( V6 t/ s+ V1 k  U  multisig                    Multisig contract commands/ t% c/ t2 ^0 x. _& N9 D' X; G
  system                      Send eosio.system contract action to the blockchain.
4 }; U' h3 W# |* X  h2 U令人惊叹的!我们跑起来了。7 y7 }# H" }" j
停止EOSIO容器
  Q4 i, ?2 p: y+ f( J当需要停止时,请使用:" x# P- |' Q! ]: {
bash docker stop eosio* e$ I) U5 P) ?
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:% S  S/ U+ w; k. \
EOS教程
, I# Q: s! i/ ~本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
: V, z+ E& ^$ t* b. D原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1