EOS开发1-开发环境配置

资料

最权威的学习资料来自https://github.com/EOSIO/eos
其他资料黎跃春区块链博客

1 硬件软件环境

当前使用Mac OS High Sierra
EOS版本使用最新的

2 编译设置开发环境

2.1 下载EOS源码

 git clone https://github.com/eosio/eos --recursive

PS:一定要加上recursive 加载所有子模块

2.2 编译源码生成可执行文件

进入刚下载的目录,输入执行指令:

./eosio_build.sh

中途如有以下提示,输入1选择安装


EOS开发1-开发环境配置_第1张图片
1.png

安装完成的提示信息:


EOS开发1-开发环境配置_第2张图片
success.png

EOS的可执行程序/eos/build/programs这个路径下面

PS:下载时间有点久,对网络要求比较高

2.3 建立区块链节点

切换到目录eos/build/programs/nodeos下面,然后执行如下命令。
./nodeos命令可附带 --data-dir 节点文件夹名字 参数,默认文件夹为nodeos。

./nodeos

修改config.ini文件,路径:
/Users/username/Library/Application Support/eosio/nodeos/config
我的文件内容如下:
做了以下配置:
enable-stale-production = true
producer-name = eosio
plugin = eosio::producer_plugin
plugin = eosio::wallet_api_plugin
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin

# the endpoint upon which to listen for incoming connections (eosio::bnet_plugin)
bnet-endpoint = 0.0.0.0:4321

# the number of threads to use to process network messages (eosio::bnet_plugin)
# bnet-threads =

# remote endpoint of other node to connect to; Use multiple bnet-connect options as needed to compose a network (eosio::bnet_plugin)
# bnet-connect =

# this peer will request no pending transactions from other nodes (eosio::bnet_plugin)
bnet-no-trx = false

# the location of the blocks directory (absolute path or relative to application data dir) (eosio::chain_plugin)
blocks-dir = "blocks"

# Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints. (eosio::chain_plugin)
# checkpoint =

# Override default WASM runtime (eosio::chain_plugin)
# wasm-runtime =

# Maximum size (in MB) of the chain state database (eosio::chain_plugin)
chain-state-db-size-mb = 1024

# Maximum size (in MB) of the reversible blocks database (eosio::chain_plugin)
reversible-blocks-db-size-mb = 340

# print contract's output to console (eosio::chain_plugin)
contracts-console = false

# Account added to actor whitelist (may specify multiple times) (eosio::chain_plugin)
# actor-whitelist =

# Account added to actor blacklist (may specify multiple times) (eosio::chain_plugin)
# actor-blacklist =

# Contract account added to contract whitelist (may specify multiple times) (eosio::chain_plugin)
# contract-whitelist =

# Contract account added to contract blacklist (may specify multiple times) (eosio::chain_plugin)
# contract-blacklist =

# Track actions which match receiver:action:actor. Actor may be blank to include all. Receiver and Action may not be blank. (eosio::history_plugin)
# filter-on =

# PEM encoded trusted root certificate (or path to file containing one) used to validate any TLS connections made.  (may specify multiple times)
#  (eosio::http_client_plugin)
# https-client-root-cert =

# true: validate that the peer certificates are valid and trusted, false: ignore cert errors (eosio::http_client_plugin)
https-client-validate-peers = 1

# The local IP and port to listen for incoming http connections; set blank to disable. (eosio::http_plugin)
http-server-address = 127.0.0.1:8888

# The local IP and port to listen for incoming https connections; leave blank to disable. (eosio::http_plugin)
# https-server-address =

# Filename with the certificate chain to present on https connections. PEM format. Required for https. (eosio::http_plugin)
# https-certificate-chain-file =

# Filename with https private key in PEM format. Required for https (eosio::http_plugin)
# https-private-key-file =

# Specify the Access-Control-Allow-Origin to be returned on each request. (eosio::http_plugin)
# access-control-allow-origin =

# Specify the Access-Control-Allow-Headers to be returned on each request. (eosio::http_plugin)
# access-control-allow-headers =

# Specify the Access-Control-Max-Age to be returned on each request. (eosio::http_plugin)
# access-control-max-age =

# Specify if Access-Control-Allow-Credentials: true should be returned on each request. (eosio::http_plugin)
access-control-allow-credentials = false

# The actual host:port used to listen for incoming p2p connections. (eosio::net_plugin)
p2p-listen-endpoint = 0.0.0.0:9876

# An externally accessible host:port for identifying this node. Defaults to p2p-listen-endpoint. (eosio::net_plugin)
# p2p-server-address =

# The public endpoint of a peer node to connect to. Use multiple p2p-peer-address options as needed to compose a network. (eosio::net_plugin)
# p2p-peer-address =

# Maximum number of client0nodes from any single IP address (eosio::net_plugin)
p2p-max-nodes-per-host = 1

# The name supplied to identify this node amongst the peers. (eosio::net_plugin)
agent-name = "EOS Test Agent"

# Can be 'any' or 'producers' or 'specified' or 'none'. If 'specified', peer-key must be specified at least once. If only 'producers', peer-key is not required. 'producers' and 'specified' may be combined. (eosio::net_plugin)
allowed-connection = any

# Optional public key of peer allowed to connect.  May be used multiple times. (eosio::net_plugin)
# peer-key =

# Tuple of [PublicKey, WIF private key] (may specify multiple times) (eosio::net_plugin)
# peer-private-key =

# Maximum number of clients from which connections are accepted, use 0 for no limit (eosio::net_plugin)
max-clients = 25

# number of seconds to wait before cleaning up dead connections (eosio::net_plugin)
connection-cleanup-period = 30

# True to require exact match of peer network version. (eosio::net_plugin)
network-version-match = 0

# number of blocks to retrieve in a chunk from any individual peer during synchronization (eosio::net_plugin)
sync-fetch-span = 100

# maximum sizes of transaction or block messages that are sent without first sending a notice (eosio::net_plugin)
max-implicit-request = 1500

# Enable block production, even if the chain is stale. (eosio::producer_plugin)
enable-stale-production = True

# Start this node in a state where production is paused (eosio::producer_plugin)
pause-on-startup = false

# Limits the maximum time (in milliseconds) that is allowed a pushed transaction's code to execute before being considered invalid (eosio::producer_plugin)
max-transaction-time = 30

# Limits the maximum age (in seconds) of the DPOS Irreversible Block for a chain this node will produce blocks on (use negative value to indicate unlimited) (eosio::producer_plugin)
max-irreversible-block-age = -1

# ID of producer controlled by this node (e.g. inita; may specify multiple times) (eosio::producer_plugin)
producer-name = eosio

# (DEPRECATED - Use signature-provider instead) Tuple of [public key, WIF private key] (may specify multiple times) (eosio::producer_plugin)
# private-key =

# Key=Value pairs in the form =
# Where:
#           is a string form of a vaild EOSIO public key
#
#        is a string in the form :
#
#        is KEY, or KEOSD
#
#    KEY:         is a string form of a valid EOSIO private key which maps to the provided public key
#
#    KEOSD:       is the URL where keosd is available and the approptiate wallet(s) are unlocked (eosio::producer_plugin)
signature-provider = EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV=KEY:5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

# Limits the maximum time (in milliseconds) that is allowd for sending blocks to a keosd provider for signing (eosio::producer_plugin)
keosd-provider-timeout = 5

# Lag in number of blocks from the head block when selecting the reference block for transactions (-1 means Last Irreversible Block) (eosio::txn_test_gen_plugin)
txn-reference-block-lag = 0

# The path of the wallet files (absolute path or relative to application data dir) (eosio::wallet_plugin)
wallet-dir = "."

# Timeout for unlocked wallet in seconds (default 900 (15 minutes)). Wallets will automatically lock after specified number of seconds of inactivity. Activity is defined as any wallet command e.g. list-wallets. (eosio::wallet_plugin)
unlock-timeout = 900

# eosio key that will be imported automatically when a wallet is created. (eosio::wallet_plugin)
# eosio-key =

# Plugin(s) to enable, may be specified multiple times
# plugin =
plugin = eosio::producer_plugin
# Wallet plugin
plugin = eosio::wallet_api_plugin
# As well as API and HTTP plugins
plugin = eosio::chain_api_plugin
plugin = eosio::http_plugin

接下来再次启动./nodeos程序,每0.5秒会产生一个区块:

3281458ms thread-0   chain_plugin.cpp:200          plugin_initialize    ] initializing chain plugin
3281467ms thread-0   block_log.cpp:123             open                 ] Log is nonempty
3281469ms thread-0   block_log.cpp:136             open                 ] my->head->block_num(): 573 
3281469ms thread-0   block_log.cpp:142             open                 ] Index is nonempty
3281498ms thread-0   wallet_plugin.cpp:41          plugin_initialize    ] initializing wallet plugin
3281499ms thread-0   http_plugin.cpp:285           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
3281499ms thread-0   net_plugin.cpp:2815           plugin_initialize    ] Initialize net plugin
3281499ms thread-0   net_plugin.cpp:2836           plugin_initialize    ] host: 0.0.0.0 port: 9876 
3281499ms thread-0   net_plugin.cpp:2908           plugin_initialize    ] my node_id is 3a795f4832207b1556e5d0b107e1b09920a4e03f772d083248bb72ecd9d66fa7
3281500ms thread-0   main.cpp:104                  main                 ] nodeos version 0961a560
3281500ms thread-0   main.cpp:105                  main                 ] eosio root is /Users/wsilverky/Library/Application Support
3281502ms thread-0   chain_plugin.cpp:409          plugin_startup       ] starting chain in read/write mode
3281502ms thread-0   chain_plugin.cpp:414          plugin_startup       ] Blockchain started; head block is #574, genesis timestamp is 2018-06-01T12:00:00.000
3281503ms thread-0   producer_plugin.cpp:577       plugin_startup       ] producer plugin:  plugin_startup() begin
3281503ms thread-0   producer_plugin.cpp:592       plugin_startup       ] Launching block production for 1 producers at 2018-06-04T08:54:41.503.
3281515ms thread-0   producer_plugin.cpp:604       plugin_startup       ] producer plugin:  plugin_startup() end
3281515ms thread-0   http_plugin.cpp:323           plugin_startup       ] start listening for http requests
3281517ms thread-0   wallet_api_plugin.cpp:68      plugin_startup       ] starting wallet_api_plugin
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/create
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/create_key
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/get_public_keys
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/import_key
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/list_keys
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/list_wallets
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/lock
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/lock_all
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/open
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/set_timeout
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/sign_digest
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/sign_transaction
3281517ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/wallet/unlock
3281517ms thread-0   chain_api_plugin.cpp:75       plugin_startup       ] starting chain_api_plugin
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/abi_bin_to_json
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/abi_json_to_bin
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_account
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_block
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_code
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_currency_balance
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_currency_stats
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_info
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_producers
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_required_keys
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/get_table_rows
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/push_block
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/push_transaction
3281518ms thread-0   http_plugin.cpp:369           add_handler          ] add api url: /v1/chain/push_transactions
3281518ms thread-0   net_plugin.cpp:2920           plugin_startup       ] starting listener, max clients is 25
3282001ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 0000023f9dbbc675... #575 @ 2018-06-04T08:54:42.000 signed by eosio [trxs: 0, lib: 574, confirmed: 0]
3282504ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 00000240e1d3f6e4... #576 @ 2018-06-04T08:54:42.500 signed by eosio [trxs: 0, lib: 575, confirmed: 0]
3283003ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 00000241a6b05d7b... #577 @ 2018-06-04T08:54:43.000 signed by eosio [trxs: 0, lib: 576, confirmed: 0]
3283501ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 0000024235949459... #578 @ 2018-06-04T08:54:43.500 signed by eosio [trxs: 0, lib: 577, confirmed: 0]
3284002ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 00000243c78cdf99... #579 @ 2018-06-04T08:54:44.000 signed by eosio [trxs: 0, lib: 578, confirmed: 0]
3284504ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 0000024452fc85e6... #580 @ 2018-06-04T08:54:44.500 signed by eosio [trxs: 0, lib: 579, confirmed: 0]
3285003ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 000002450a94fc1a... #581 @ 2018-06-04T08:54:45.000 signed by eosio [trxs: 0, lib: 580, confirmed: 0]
3285501ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 00000246f564bac6... #582 @ 2018-06-04T08:54:45.500 signed by eosio [trxs: 0, lib: 581, confirmed: 0]
3286003ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 00000247fe1aed81... #583 @ 2018-06-04T08:54:46.000 signed by eosio [trxs: 0, lib: 582, confirmed: 0]
3286505ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 000002489c0b9de8... #584 @ 2018-06-04T08:54:46.500 signed by eosio [trxs: 0, lib: 583, confirmed: 0]
3287002ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 0000024966bb0805... #585 @ 2018-06-04T08:54:47.000 signed by eosio [trxs: 0, lib: 584, confirmed: 0]
3287504ms thread-0   producer_plugin.cpp:1073      produce_block        ] Produced block 0000024af551e428... #586 @ 2018-06-04T08:54:47.500 signed by eosio [trxs: 0, lib: 585, confirmed: 0]

3 获取区块信息

重新打开个终端,切换到cleos文件夹:
/Users/username/Documents/gitTools/eos/eos/build/programs/cleos
输入以下命令:

wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get info
{
  "server_version": "0961a560",
  "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
  "head_block_num": 907,
  "last_irreversible_block_num": 906,
  "last_irreversible_block_id": "0000038a857f5b3dc2b0343d1b55b18c7d23abea6935c2303e17d8ed6ed65770",
  "head_block_id": "0000038b14ec25e9b9dcc2f3eb0e4d1b4d6b40533c44400d29e1e80d13655a9a",
  "head_block_time": "2018-06-04T08:57:28",
  "head_block_producer": "eosio",
  "virtual_block_cpu_limit": 494365,
  "virtual_block_net_limit": 2595046,
  "block_cpu_limit": 199900,
  "block_net_limit": 1048576
}
wsilverkydeMacBook-Pro:cleos wsilverky$ ./cleos get info
{
  "server_version": "0961a560",
  "chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
  "head_block_num": 913,
  "last_irreversible_block_num": 912,
  "last_irreversible_block_id": "000003905da80c4f7ceaa1ed95e9284a6a4257a8c0cdcd01c51ee6859fef5df3",
  "head_block_id": "00000391cd7fda726dce92d506f1c06abd328c13fb17b25c1cacb75da9e8b9e6",
  "head_block_time": "2018-06-04T08:57:31",
  "head_block_producer": "eosio",
  "virtual_block_cpu_limit": 497338,
  "virtual_block_net_limit": 2610668,
  "block_cpu_limit": 199900,
  "block_net_limit": 1048576
}

你可能感兴趣的:(EOS开发1-开发环境配置)