Skip to content

Development Tips

Thomas edited this page Feb 25, 2018 · 56 revisions

Hello ChainLink

We have a repo of example apps, Hello ChainLink, that you may find useful when developing apps that use ChainLink.

devnet/cldev

In order to make it easy to develop locally with Ethereum, we have packaged up an Ethereum development network in a docker node, and pre-funded an account for your development ChainLink node.

In order to use devnet:

  1. Install Docker
  2. Add internal/bin to your path via direnv (Optional, alternatively prefix all {devnet,cldev} commands with ./internal/bin)
  3. Open a new window and start the network:
$ ./devnet
  1. Deploy the related contracts:
$ cd solidity && truffle migrate --network devnet
  1. Run your local version of ChainLink against devnet:
./cldev node
  1. Open a new window and explore devnet via a truffle console:
$ cd solidity && truffle console --network devnet

Geth

Geth needs to be invoked with websockets enabled. An example of how to do this is:

geth --light --ws --wsaddr 127.0.0.1 --wsport 8546 --wsorigins "*"

This would make Geth listen on ws://127.0.0.1:8546 and accept all incoming connections. Alternatively, you could change the --wsorigins parameter to 127.0.0.1 as well to only accept local connections.

direnv

We use direnv to set up PATH and aliases for a friendlier developer experience. Here is an example .envrc that we use:

$ cat .envrc
export ROOT=tmp/.chainlink
PATH_add internal/bin
PATH_add solidity/node_modules/.bin
PATH_add tmp

Direnv can be installed by running

$ go get -u github.com/direnv/direnv

Environment variables that can be set in .envrc, along with default values that get used if no corresponding enviornment variable is found:

LOG_LEVEL                Default: info
ROOT                     Default: ~/.chainlink
PORT                     Default: 6688
USERNAME                 Default: chainlink
PASSWORD                 Default: twochains
ETH_URL                  Default: ws://localhost:8546
ETH_CHAIN_ID             Default: 0
CLIENT_NODE_URL          Default: http://localhost:6688
ETH_MIN_CONFIRMATIONS    Default: 12
ETH_GAS_BUMP_THRESHOLD   Default: 12
ETH_GAS_BUMP_WEI         Default: 5000000000  (5 gwei)
ETH_GAS_PRICE_DEFAULT    Default: 20000000000 (20 gwei)

Colorized Test Output

Use grc to colorize your test output and make it more readable.

Development Dependencies

The following is a list of dependencies that need to be installed on the host machine, categorized by role.

Chainlink

  • Go
  • gcc (for secp256k1 in go-ethereum)

Devnet

  • Docker

Solidity contract development

  • Node.js & npm
  • Yarn
  • Truffle

Clone this wiki locally