通过docker快速安装构建EOSIO开发环境
4645979
发表于 2022-11-12 14:09:06
112
0
0
Docker: Docker管理服务。Docker旨在通过使开发人员在容器内很方便的创建完全配置的系统环境来简化应用程序部署。系统环境包括在配置好的操作系统中运行各种目标应用程序,这些目标应用程序提供你的应用程序需要的所有运行时支持。开发人员在容器内创建所需的系统配置,然后在打包容器进行分发。6 t) h$ c% Y' ]2 D
1.获取镜像& r: V* k& c! w2 U4 M9 V; M
EOSIO Dev docker镜像是为本地开发而设计的EOSIO软件的编译版本。
从存储库中提取镜像:
docker pull eosio/eos-dev
4 Q; B; e' ^0 x& U) D0 b8 d
开启EOSIO节点' D6 U, Y5 z/ a' u4 @
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"
检查它的工作情况:
docker logs --tail 10 eosio
输出应该类似这样:- z+ A$ D6 W$ 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]
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]3 X: n9 r y( i% e- d4 M; F) C
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]! G6 H) r ]3 A( K% n$ r& i
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]
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]- b, z6 ]. B. L3 y# D" b! b
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]
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]
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]! O, E1 [: c6 x1 o8 v/ B; R0 C
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]* A2 p7 F6 P# A) ]0 V- E7 }
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]
恭喜!你有一个非常简单的单节点区块链运行在你的docker中!
也可以通过浏览器中的这个地址来检查RPC接口是否工作:& h+ X5 i3 O8 J' H) q. t. e
http://localhost:8888/v1/chain/get_info4 p$ _- B& l) O. W4 K
你应该看到类似的信息:: W9 k* a6 E6 r; f
{: R. {+ z5 e" ]$ ^) p
"server_version": "0961a560",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f", b0 u/ }9 F' e I1 E: i* g
"head_block_num": 13780, q2 Y; |- I0 f4 M% X
"last_irreversible_block_num": 13779,) {+ c& m$ z+ R5 g4 ?2 D* G% q$ w. m
"last_irreversible_block_id": "000035d36e1ca29ba378081c574ab3b5ab4214ba29754dd42b512690a9f03e80",4 U: C0 i1 Z N! m
"head_block_id": "000035d4165c9225d7a04822d142fbcb15f997a6f2571dc7bae8437dea782205",$ f! b% X1 c) S% W( a1 `
"head_block_time": "2018-05-23T16:30:54",
"head_block_producer": "eosio",5 S. W! a# t3 A v- @
"virtual_block_cpu_limit": 100000000,
"virtual_block_net_limit": 1048576000,
"block_cpu_limit": 99900,
"block_net_limit": 1048576
}) L- P6 O% N2 \$ U+ X& d4 Y; `% { L
2.Cleos别名
cleos是一个命令行接口,负责与区块链交互并管理钱包。
为了方便起见,我们将创建一个bash别名,用于运行在容器中的cleos。在终端,运行:0 _% V$ u: a8 U5 T
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'
3.确认是否安装成功
现在试着在你的终端中运行cleos --help。你应该看到一个输出:7 x& D' ]3 n, @" l
Command Line Interface to EOSIO Client; N( \! Q0 r# C8 e$ E
Usage: /opt/eosio/bin/cleos [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit2 g' N- A6 I8 I j" q
-u,--url TEXT=http://localhost:8888/
the http/https URL where nodeos is running
--wallet-url TEXT=http://localhost:8900/' `. `0 p: K5 n: k: E; }
the http/https URL where keosd is running w3 N. E s8 ^) M
-r,--header pass specific HTTP header; repeat this option to pass multiple headers
-n,--no-verify don't verify peer certificate when using HTTPS
-v,--verbose output verbose actions on error
Subcommands:" @/ }: V5 o, C, @3 O3 P* L
version Retrieve version information: ~4 e2 g% M- ?) O3 `6 [
create Create various items, on and off the blockchain
get Retrieve various items and information from the blockchain
set Set or update blockchain state6 w- e5 z$ a6 [; T' @3 ?4 d* W
transfer Transfer EOS from account to account6 r" ]' d- B8 T, ^ a4 g5 h4 `
net Interact with local p2p network connections
wallet Interact with local wallet5 U$ l, C7 O2 [0 V( y
sign Sign a transaction
push Push arbitrary transactions to the blockchain
multisig Multisig contract commands
system Send eosio.system contract action to the blockchain.6 N1 t. b6 p% S- X% u# w
令人惊叹的!我们跑起来了。
停止EOSIO容器( s' L( | { ~% d& M* }/ Q
当需要停止时,请使用:0 A- G9 L7 q% Z: W
bash docker stop eosio
另:**《EOS智能合约与DApp开发入门》**教程已经上线,欢迎大家关注:7 s& \4 g; L: C" |: S
EOS教程
本教程帮助你快速入门EOS区块链去中心化应用的开发,内容涵盖EOS工具链、账户与钱包、发行代币、智能合约开发与部署、使用代码与智能合约交互等核心知识点,最后综合运用React和EOS的各知识点完成一个便签DApp的开发。
原文
成为第一个吐槽的人