Hi 游客

更多精彩,请登录!

比特池塘 区块链技术 正文

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

4645979
149 0 0
先决条件) m7 Y! a2 |( R. H# I- v2 t1 {
Docker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。7 L! `8 l: m2 u: t+ g% E* T
1.获取镜像, M, I+ R2 O% j2 M1 P# H) C0 V
EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。
" [" v& Q; }; Q" v从存储库中提取镜像:& E& J! }+ C: i# n4 B
docker pull eosio/eos-dev
- P9 n- f) R: p$ K, g0 m) M) w* d8 @' L1 `( s8 q
开启EOSIO节点" L# r1 z& V- r
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"
) l0 D" K* ^  C  Y- X检查它的工作情况:- k, z$ h9 ?4 w4 n
docker logs --tail 10 eosio
7 A. f) B5 c3 X9 }# v9 H% B: u. r! W输出应该类似这样:
8 }( H" }5 Z! r' ]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]
" c1 [/ b1 X. F) v1929502ms 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]
: K8 k0 t' [+ @' u1930002ms 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 X7 O9 _: q) h5 G1930501ms 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]
& K% f* R2 r/ {8 h0 ~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]
3 |2 M  b) u& d$ _: I1931501ms 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]
+ W# ]- G7 ?3 B6 `$ k1932001ms 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]
, j3 v, k8 K3 g% S1932501ms 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]
$ W+ W/ Y+ o- c! l# v$ x9 z# N9 I1933001ms 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]
5 ~& l: v4 F. v1933501ms 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( m8 o3 l' ^1 [5 k$ ^恭喜!你有一个非常简单的单节点区块链运行在你的docker中!
4 y& [9 u( z7 M& G5 {也可以通过浏览器中的这个地址来检查RPC接口是否工作:
4 W! N2 x: s: D' \1 L1 shttp://localhost:8888/v1/chain/get_info" D7 U' w2 O; }, r* D
你应该看到类似的信息:/ e# E1 d8 w& o" q) E$ i! L
{
: Q4 {  L+ P# p$ b# H% Z0 D! H    "server_version": "0961a560",, Z: \' U. w+ t" m
    "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",6 d" c! L* e& v) Y, y
    "head_block_num": 13780,
% @6 t% L5 }: \6 y    "last_irreversible_block_num": 13779,) n! f! X4 C2 @, o6 N; _
    "last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",
* o: O8 R+ P1 h: p    "head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",
7 G: Z0 G  h5 ~  b1 t  `, p    "head_block_time": "2018-05-23T16:30:54",; V5 x4 w# ~7 p  I$ i
    "head_block_producer": "eosio"," \0 {0 }# g$ p* y  X
    "virtual_block_cpu_limit": 100000000,
5 f" q+ N6 z+ s: {    "virtual_block_net_limit": 1048576000,( o% y( v7 s5 M" I( w
    "block_cpu_limit": 99900,2 x) A* t  i- C# g/ C
    "block_net_limit": 1048576
. x( H( s( Y! p1 T1 N% b}6 I6 k/ W+ ^+ a1 r: c6 u* e1 R
2.Cleos别名' J+ ]( ~9 Y- j0 }7 N# P3 S
cleos是一个命令行接口,负责与区块链交互并管理钱包。
4 V$ ~, F2 ?- Q. e& \+ v' Q为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:
. Y2 A5 Y, d# U9 qalias cleos='docker exec -it eosio /opt/eosio/bin/cleos -u http://0.0.0.0:8888 --wallet-url http://0.0.0.0:8888'
) {* H2 [/ T# U3.确认是否安装成功4 k5 w9 F* I3 E3 r
现在试着在你的终端中运行cleos --help。你应该看到一个输出:
  p$ ]0 i5 u5 sCommand Line Interface to EOSIO Client+ u2 u# J( Z, \: G0 e6 s; I% v
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND
& k2 F4 C& l! r4 ]" U3 u$ tOptions:2 `3 ~! U! g6 ]; |( P: l7 m- K
  -h,--help                   Print this help message and exit! ~# }$ T* X! ~
  -u,--url TEXT=http://localhost:8888/8 o+ W1 x0 d1 V
                              the http/https URL where nodeos is running5 p5 K# v8 f: @: r7 J3 j
  --wallet-url TEXT=http://localhost:8900/
) U$ F$ J: ^2 l                              the http/https URL where keosd is running
. p3 h$ n2 H$ |5 h  -r,--header                 pass specific HTTP header; repeat this option to pass multiple headers
, s8 u5 g$ e( Q" T( e! Q  -n,--no-verify              don't verify peer certificate when using HTTPS# V0 y1 ~6 x, O, w" ^
  -v,--verbose                output verbose actions on error1 o* @3 G; X+ k: F* Z
Subcommands:. m' P7 Z; G+ {) H7 M
  version                     Retrieve version information
1 @$ p: G2 h5 u- g1 v  create                      Create various items, on and off the blockchain
5 V5 ], K. V  P* }2 `, V  get                         Retrieve various items and information from the blockchain1 E; V) ^) P+ J: x4 x
  set                         Set or update blockchain state# t3 z% f# z7 @; ^  j
  transfer                    Transfer EOS from account to account
: B4 d, I! r% i8 s# L/ Y1 I5 P  net                         Interact with local p2p network connections
0 p- f- ~1 i- N  wallet                      Interact with local wallet, b2 e1 w5 D9 ^: D0 M
  sign                        Sign a transaction1 m5 l1 Q  P8 k4 A+ B
  push                        Push arbitrary transactions to the blockchain
0 R& l, }- J$ n6 x  T- _  multisig                    Multisig contract commands5 E3 B: ~) f- g5 ?. v
  system                      Send eosio.system contract action to the blockchain.$ ?+ C: V7 `0 k6 x$ ?. X. a
令人惊叹的!我们跑起来了。* G  n& n( r) u' R$ q- J9 p
停止EOSIO容器, F' S% |) t1 p3 S( f& U- G; _9 h
当需要停止时,请使用:) H! ~2 g% F" m3 B% n
bash docker stop eosio. p# ?2 D. C& l5 h0 T
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:! X7 [% S& y: i+ ?6 A5 u
EOS教程  F7 h$ I" B9 M5 ^
本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。0 O6 `) F$ t8 l
原文
BitMere.com 比特池塘系信息发布平台,比特池塘仅提供信息存储空间服务。
声明:该文观点仅代表作者本人,本文不代表比特池塘立场,且不构成建议,请谨慎对待。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

成为第一个吐槽的人

4645979 小学生
  • 粉丝

    0

  • 关注

    0

  • 主题

    1