Skip to content

Instantly share code, notes, and snippets.

@cookie-ag
Last active November 8, 2018 15:30
Show Gist options
  • Save cookie-ag/b58615d49c0f92cddd26b8eda6053ab9 to your computer and use it in GitHub Desktop.
Save cookie-ag/b58615d49c0f92cddd26b8eda6053ab9 to your computer and use it in GitHub Desktop.
EOSIO Setup for development (OSX)
(a) Show images
docker image ls
(b) Show containers
docker container ls
(c) Access docker bash for a container
docker exec -it $CONTAINERID /bin/bash
(c) More
https://www.digitalocean.com/community/tutorials/naming-docker-containers-3-tips-for-beginners
#Nodeos
the core EOSIO daemon that can be configured with plugins to run a node. Example uses are block production, dedicated API endpoints, and local development.
(a) Download IMAGE for Development
docker pull eosio/eos-dev
(b) Start the container from the image
-> OSX
sudo docker run --rm --name nodeos -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"
-> WIN 10
docker network create eosdev
docker run --name nodeos -d -p 8888:8888 --network eosdev -v C:\eosio\work:/work -v C:\eosio\data:/mnt/dev/data -v C:\eosio\config:/mnt/dev/config eosio/eos-dev /bin/bash -c "nodeos -e -p eosio --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"
(c) See if this image is working
sudo docker logs --tail 10 eosio
(d) Got to the web-browser
http://localhost:8888/v1/chain/get_info
(e) Stop/Start container
docker stop nodeos
docker start nodeos
#Cleos
cleos is a command line tool that interfaces with the REST API exposed by nodeos. In order to use cleos you will need to have the end point (IP address and port number) to a nodeos instance and also configure cleos to load the 'eosio::chain_api_plugin'. cleos contains documentation for all of its commands
(a) Create a alias so as cleos is available from terminal
alias cleos='docker exec eosio /opt/eosio/bin/cleos --wallet-url http://localhost:8888'
(b) Create Key
cleos create key
(c) Create Wallet/List all wallets
cleos wallet create
cleos wallet list
(d) Open a wallet
cleos wallet open
(e) Unlock a wallet (Assuming you opened a default)
cleos wallet unlock --password XXXXXXXmypassword
(f) Relate private keys inside your wallet and your wallet is unlocked
cleos wallet import myprivatekeyXXXXX
(g) Create Account (First time user should be eosio)
cleos create account eosio $ACCOUNTNAME EOSXXXPublicKey EOSXXXPublicKey
# This is very useful when creating accounts. Always use eosio as the creator for local development.
(h) Get block/account/code or abi info
cleos get info
cleos get account eosio
cleos get code eosio.token
(i) Get table for specific contract
cleos get table eosio.token eosio accounts
(j) Get table for specific contract
cleos get currency balance eosio.token eosio SYMBOL
Before anything go through the communication doc: https://developers.eos.io/eosio-cpp/docs/communication-model
# We need to setup a tool call eosiocpp
(a) Create a alias so as eosiocpp is available from terminal
alias eosiocpp='docker exec eosio eosiocpp'
(b) Create a new contract from template
eosiocpp -n ${contract}
(c) Access this new contract file
docker exec -it $CONTAINERID /bin/bash
cd ${contract}
-> This is the place where we have our smart contract hpp and cpp file.
(d) Create wast/wasm from cpp
eosiocpp -o ${contract}.wast ${contract}.cpp
(e) Create abi file from hpp
eosiocpp -g ${contract}.abi ${contract}.hpp
(f) set contract to the block chain
cleos set contract $CURRENCY ${contract}.wast ${contract}.abi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment