Skip to content

Instantly share code, notes, and snippets.

@gosuri
Last active July 9, 2018 04:10
Show Gist options
  • Save gosuri/f42b629c3c42e828c027be154469641a to your computer and use it in GitHub Desktop.
Save gosuri/f42b629c3c42e828c027be154469641a to your computer and use it in GitHub Desktop.
Running EOS on OSX Darwin (MacOS)

Instructions to setup EOS node on a Mac

Install EOS Binaries

I was unable to find EOS binaries online so I built them on my workstation. This process take a little over 15 minutes. To begin, download the source from github and build using the script.

$ mkdir -p ~/EOSIO
$ git clone https://github.com/EOSIO/eos --recursive
$ cd ~/EOSIO/eos
$ ./eosio_build.sh # Follow onscreen instructions
$ cd ./build
$ make install # Install to /usr/local

Potential issues building on Darwin

Incase your build fails, it is most likely due to a missing a dependency. Few issues I've faced:

  • Failed to find Gettext libintl (missing: Intl_INCLUDE_DIR): EOSIO/eos#2240

Run the node

You can start your a single-node EOS blockchain with this single command with a default configuration. You should see a block being created every 0.5 seconds:

$ nodeos -e -p eosio --plugin eosio::chain_api_plugin --plugin eosio::history_api_plugin

2945273ms thread-0   chain_plugin.cpp:209          plugin_initialize    ] initializing chain plugin
2945273ms thread-0   chain_plugin.cpp:395          plugin_initialize    ] Starting up fresh blockchain with default genesis state.
2946599ms thread-0   http_plugin.cpp:290           plugin_initialize    ] configured http to listen on 127.0.0.1:8888
2946601ms thread-0   net_plugin.cpp:2948           plugin_initialize    ] Initialize net plugin
2946601ms thread-0   net_plugin.cpp:2972           plugin_initialize    ] host: 0.0.0.0 port: 9876
2946601ms thread-0   net_plugin.cpp:3044           plugin_initialize    ] my node_id is 2361304bb0915d1cf2c68a649d19ef3b0deef4847356570150dff4ba26de0faf
2946602ms thread-0   main.cpp:104                  main                 ] nodeos version 5875549c
2946602ms thread-0   main.cpp:105                  main                 ] eosio root is /Users/gosuri/Library/Application Support
...

Create a wallet

Create a wallet using wallet create subcommand. A wallet with the name default will be create if a name is unspecified.

$ cleos -u http://127.0.0.1:8888 --wallet-url http://127.0.0.1:8889 wallet create

"/usr/local/bin/keosd" launched
Creating wallet: default
Save password to use in the future to unlock this wallet.
Without password imported keys will not be retrievable.
"PW5HtJaAwPQt65dF6mkanXFDC4q4gQh2rdD6wbnv35QPwWiGKJTAR"

Save the password for later use. You'll need to unlock the wallet to use. The wallet should be unlocked by default upon creation, otherwise use the unlock command with the password.

$ cleos --wallet-url http://127.0.0.1:8889 wallet import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

Load the Tutorial Key

$ cleos wallet --wallet-url http://127.0.0.1:8889 import 5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3

Load the Bios Contract

$ cleos --wallet-url http://127.0.0.1:8889 set contract eosio build/contracts/eosio.bios -p eosio@active

Reading WAST/WASM from build/contracts/eosio.bios/eosio.bios.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 0d46c9791616d063f09956568101d1d02127a50ae51c14ebbbad98328abcbb15  3720 bytes  5449 us
#         eosio <= eosio::setcode               {"account":"eosio","vmtype":0,"vmversion":0,"code":"0061736d0100000001621260037f7e7f0060057f7e7e7e7e...
#         eosio <= eosio::setabi                {"account":"eosio","abi":"0e656f73696f3a3a6162692f312e30050c6163636f756e745f6e616d65046e616d650f7065...
warning: transaction executed locally, but may not be confirmed by the network yet

Create accounts

Create two accounts user and tester accounts for testing and associate a key for each account. For simplicity, use the same key for both the accounts. First, create a key:

$ cleos --wallet-url http://127.0.0.1:8889 create key

Private key: 5KX6P4mt5tgWift9EiqSgvhRdbYjtWLTcLATzGY5D99LgK3byVo
Public key: EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

Then import they key to our default wallet:

$ cleos --wallet-url http://127.0.0.1:8889 wallet import 5KX6P4mt5tgWift9EiqSgvhRdbYjtWLTcLATzGY5D99LgK3byVo

imported private key for: EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

Next, create the accounts for user and tester using the Public key we created in the above step.

$ cleos --wallet-url http://127.0.0.1:8889 create account eosio user EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

executed transaction: 39c21344c50f6c58c0a750cc8d6546df92ac6274a515374e17bbcf5cc4830f92  200 bytes  1573 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"user","owner":{"threshold":1,"keys":[{"key":"EOS5VHN2wYSoCtjUCixjdAexMb9g...
warning: transaction executed locally, but may not be confirmed by the network yet

Repeat for tester:

$ cleos --wallet-url http://127.0.0.1:8889 create account eosio tester EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

executed transaction: feec75c1d6d33a9e8554fea794f63e3b8f7d6fafa95269585ccda4bb4dea3cf1  200 bytes  174 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"tester","owner":{"threshold":1,"keys":[{"key":"EOS5VHN2wYSoCtjUCixjdAexMb...
warning: transaction executed locally, but may not be confirmed by the network yet

Verify the accounts a created using get accounts subcommand:

$ cleos --wallet-url http://127.0.0.1:8889 get accounts EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

Create a EOSIO Token Contract

Deploy an eosio.token contract to enable creation of different token tokens all running on the same contract but potentially managed by different users.

Unlock the wallet, with the password we generated during wallet creation:

$ cleos --wallet-url http://127.0.0.1:8889 wallet unlock --password PW5HtJaAwPQt65dF6mkanXFDC4q4gQh2rdD6wbnv35QPwWiGKJTAR

Before we can deploy the token contract we must create an account to deploy it to:

$ cleos --wallet-url http://127.0.0.1:8889 create account eosio eosio.token EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68 EOS5VHN2wYSoCtjUCixjdAexMb9g9BrKyMrWSrSX9Us7AwnzeDA68

executed transaction: 675ec0ddfbb85d870ff5bdd453f54360d36d975a02929e632197453b3834cbd9  200 bytes  193 us
#         eosio <= eosio::newaccount            {"creator":"eosio","name":"eosio.token","owner":{"threshold":1,"keys":[{"key":"EOS5VHN2wYSoCtjUCixjd...
warning: transaction executed locally, but may not be confirmed by the network yet

Then deploy the contract found under ${EOSIO_SOURCE}/build/contracts/eosio.token

$ cleos --wallet-url http://127.0.0.1:8889 set contract eosio.token build/contracts/eosio.token -p eosio.token@active

Reading WAST/WASM from build/contracts/eosio.token/eosio.token.wasm...
Using already assembled WASM...
Publishing contract...
executed transaction: 053acf37b2a6b0d5c1b2767a5ee1558a840adebc3fecefa455279392d66f6955  8104 bytes  1356 us
#         eosio <= eosio::setcode               {"account":"eosio.token","vmtype":0,"vmversion":0,"code":"0061736d01000000017e1560037f7e7f0060057f7e...
#         eosio <= eosio::setabi                {"account":"eosio.token","abi":"0e656f73696f3a3a6162692f312e30010c6163636f756e745f6e616d65046e616d65...
warning: transaction executed locally, but may not be confirmed by the network yet

Create the Currency Token "SYS"

Create a new token using create(...) action with issuer and maximum_supply as the arguments. The concise way to call this method, using positional arguments:

$ cleos --wallet-url http://127.0.0.1:8889 push action eosio.token create '[ "eosio", "1000000000.0000 SYS"]' -p eosio.token@active

executed transaction: d7271054e77eafdb8aec6537ec4a90d982015b7bc9bf5bd9ed0cb5d6f3849295  120 bytes  1661 us
#   eosio.token <= eosio.token::create          {"issuer":"eosio","maximum_supply":"1000000000.0000 SYS"}
warning: transaction executed locally, but may not be confirmed by the network yet

This command created a new token SYS with a precision of 4 decimals and a maximum supply of 1000000000.0000 SYS.

In order to create this token we required the permission of the eosio.token contract because it "owns" the symbol namespace (e.g. "SYS"). Future versions of this contract may allow other parties to buy symbol names automatically. For this reason we must pass -p eosio.token@active to authorize this call.

Issue Tokens to Account "User"

$ cleos --wallet-url http://127.0.0.1:8889 push action eosio.token issue '[ "user", "100.0000 SYS", "memo" ]' -p eosio@active

executed transaction: 82091986c04a8acedf489223921a55208a65e40c2e2a53715e931f56614377e8  128 bytes  1310 us
#   eosio.token <= eosio.token::issue           {"to":"user","quantity":"100.0000 SYS","memo":"memo"}
#   eosio.token <= eosio.token::transfer        {"from":"eosio","to":"user","quantity":"100.0000 SYS","memo":"memo"}
#         eosio <= eosio.token::transfer        {"from":"eosio","to":"user","quantity":"100.0000 SYS","memo":"memo"}
#          user <= eosio.token::transfer        {"from":"eosio","to":"user","quantity":"100.0000 SYS","memo":"memo"}
warning: transaction executed locally, but may not be confirmed by the network yet

Transfer Tokens to Account "Tester"

Transfer a few tokens from user account to tester account.

$ cleos --wallet-url http://127.0.0.1:8889 push action eosio.token transfer '[ "user", "tester", "25.0000 SYS", "m" ]' -p user@active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment