How to Set up EOSIO Development Environment and Run

RayonProtocol
RayonProtocol
Published in
5 min readJul 5, 2018

Let’s build an environment for developing DApps that run on the EOS platform.

For our reference, we used the local environment set-up in the official EOSIO wiki document.

EOSIO Components

EOSIO has three components.

  • nodeos : node component that manages blockchain
  • keosd: component that manages wallet
  • cleos: CLI that controls blockchain and wallet

Install EOSIO

In this article, we explain our topic based on MaxOS Darwin 10.12.

First, please clone the source code from EOSIO git

$ git clone https://github.com/EOSIO/eos --recursive

Xcode and homebrew should be installed to build the source code. In case the two are not installed, please install Xcode and homebrew first.

When running the build script inside the source code, the build will be done automatically.

$ cd eos$ ./eosio_build.sh

After the build has been done successfully, the below messages will appear.

[100%] Linking CXX executable unit_test[100%] Built target unit_test_______  _______  _______ _________ _______(  ____ \(  ___  )(  ____ \\__   __/(  ___  )| (    \/| (   ) || (    \/   ) (   | (   ) || (__    | |   | || (_____    | |   | |   | ||  __)   | |   | |(_____  )   | |   | |   | || (      | |   | |      ) |   | |   | |   | || (____/\| (___) |/\____) |___) (___| (___) |(_______/(_______)\_______)\_______/(_______)EOSIO has been successfully built. 00:11:21To verify your installation run the following commands:/usr/local/bin/mongod -f /usr/local/etc/mongod.conf &cd /Users/scion/git/eos/build; make testFor more information:EOSIO website: https://eos.ioEOSIO Telegram channel @ https://t.me/EOSProjectEOSIO resources: https://eos.io/resources/EOSIO Stack Exchange: https://eosio.stackexchange.comEOSIO wiki: https://github.com/EOSIO/eos/wiki

Troubleshooting

  1. When an error like the below occurs during the process of the build:
CMake Error at /usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.11.3/share/cmake/Modules/FindIntl.cmake:47 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
programs/cleos/CMakeLists.txt:29 (find_package)

In this case, we need to modify the connection information, as homebrew and gettext are connected with different versions.

$ brew link gettext — force

Adding gettext path to (~/.profile)

export PATH=”/usr/local/opt/gettext/bin:$PATH”

Reference : https://github.com/EOSIO/eos/issues/2174

2. When an error like the below occurs in the process of the build:

Mac OS 10.13.3 build error “path mongo-cxx-driver already exists”

Please follow the below command:

sudo rm -rf /tmp/mongo*
cd /path/to/eos
rm -rf build/
git pull
git submodule update — init — recursive
./eosio_build.sh

Reference : https://github.com/EOSIO/eos/issues/3197

Confirm

Let’s run a test script to verify if the build has been done successfully.

$ /usr/local/bin/mongod -f /usr/local/etc/mongod.conf &$ cd build/$ make testRunning tests...Test project /Users/scion/git/eos/buildStart  1: test_cypher_suites1/35 Test  #1: test_cypher_suites ...................   Passed    0.04 secStart  2: validate_simple.token_abi2/35 Test  #2: validate_simple.token_abi ............   Passed    0.08 secStart  3: validate_eosio.token_abi...34/35 Test #34: restart-scenarios-test-hard_replay ...   Passed  151.83 secStart 35: validate_dirty_db_test35/35 Test #35: validate_dirty_db_test ...............   Passed    4.42 sec100% tests passed, 0 tests failed out of 35

Let’s install the program that completes the build.

$ cd build$ sudo make install

Run EOSIO

Let’s run several components in EOSIO. Let’s do this with 1 node as it is mainly for constructing a development environment.

nodeos

Please run with the below command option.

$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin
  • -e : run block production
  • -p eosio : set up producer name
  • — plugin eosio::chain_api_plugin : run API related to chain
  • — plugin eosio::history_api_plugin : run API related to history

You can only run ‘keosd’ without options after completing the config file.

  • config file location: ‘~/Library/Application Support/eosio/nodeos/config/config.ini’
  • When running ‘keosd’ first, the corresponding file is automatically generated.
$ vi ~/Library/Application\ Support/eosio/nodeos/config/config.ini

...
# enable-stale-production = false
enable-stale-production = true
...
# producer-name =
producer-name = eosio
...
plugin = eosio::chain_api_plugin
plugin = eosio::history_api_plugin
...

Run nodeos:

$ nodeos

If it runs normally, you can see a message indicating the creation of a block every 0.5 seconds.

Let’s run an API to verify if ‘nodeos’ is running properly.

Make a HTTP Request to the API server at port of 8888.

$ curl -k -v 'http://127.0.0.1:8888/v1/chain/get_info' -X GET

Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET /v1/chain/get_info HTTP/1.1
> Host: 127.0.0.1:8888
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Length: 529
< Content-type: application/json
< Server: WebSocket++/0.7.0
<
{"server_version":"012dc012","chain_id":"cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f","head_block_num":363,"last_irreversible_block_num":362,"last_irreversible_block_id":"0000016ad0238cef2f6a8de2098115ba155cbbc535122912a7a62f66097adbd6","head_block_id":"0000016b8cbb9154a759f2e61968fc1069fcf0ef9468886614d0538a97d96c61","head_block_time":"2018-06-12T07:10:59","head_block_producer":"eosio","virtual_block_cpu_limit":287075,"virtual_block_net_limit":1506023,"block_cpu_limit":199900,"block_net_limit":1048576}

Or run it through the below ‘cleos’ command:

$ cleos get info
{
"server_version": "012dc012",
"chain_id": "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f",
"head_block_num": 580,
"last_irreversible_block_num": 579,
"last_irreversible_block_id": "000002436a1baaeb366b55995ddad7de0822f177d60a8c6e336e3f5fcb18ecc5",
"head_block_id": "00000244e6923239c0649ddada0dd47a2df80df13fa825275df9ddac975e6162",
"head_block_time": "2018-06-12T07:12:48",
"head_block_producer": "eosio",
"virtual_block_cpu_limit": 356561,
"virtual_block_net_limit": 1871085,
"block_cpu_limit": 199900,
"block_net_limit": 1048576
}

keosd

Run with the below command option:

$ keosd — http-server-address=127.0.0.1:8900
  • — http-server-address : since the nodeos’s default port of REST API is 8888, let’s use 8900 port for avoiding a collision. We should use 8900 for us to later use it, in cleos, without designating an URL as the port would be recognized as a default port.

You can only run ‘keosd’ after completing config file instead of the option.

  • config file location: ~/eosio-wallet/config.ini
  • When running ‘keosd’ first, the corresponding file is automatically generated.
$ vi ~/eosio-wallet/config.ini

# http-server-address = 127.0.0.1:8888
http-server-address = 127.0.0.1:8900

Run keosd:

$ keosd

Make a HTTP Request to API server at 8900:

$ curl -k -v ‘http://127.0.0.1:8900/v1/wallet/list_wallets' -X GETNote: Unnecessary use of -X or — request, GET is already inferred.
* Trying 127.0.0.1…
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8900 (#0)
> GET /v1/wallet/list_wallets HTTP/1.1
> Host: 127.0.0.1:8900
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Length: 2
< Content-type: application/json
< Server: WebSocket++/0.7.0
<
[]

Or run it through the below ‘cleos’ command:

$ cleos wallet list
Wallets:
[]

If ‘nodeos’ and ‘keosd’ are properly running, then you can use EOSIO services.

--

--