Skip to content

node of the decentralized oracle network, bridging on and off-chain computation

License

Notifications You must be signed in to change notification settings

faretdinovfi/chainlink

Repository files navigation

Chainlink Travis-CI CodeCov

Developer Setup

Install Go 1.9+

Create the Go workspace (~/go given as an example)

$ mkdir ~/go && cd ~/go

Set environment variables

$ export GOPATH=$(pwd)
$ export PATH=$PATH:$GOPATH/bin

Create Project Directories

$ cd $GOPATH
$ mkdir -p src/github.com/smartcontractkit
$ cd src/github.com/smartcontractkit

Clone the repo

$ git clone https://github.com/smartcontractkit/chainlink.git
$ cd chainlink

Get and run dep

Linux

$ go get -u github.com/golang/dep/cmd/dep
$ dep ensure

Mac

$ brew install dep
$ dep ensure

Build the project

$ go build -o chainlink

Run the binary

$ ./chainlink

Testing

$ cd $GOPATH/src/github.com/smartcontractkit/chainlink
$ go test ./...

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
PATH_add tmp
PATH_add solidity/node_modules/.bin

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
POLLING_SCHEDULE         Default: */15 * * * * *
CLIENT_NODE_URL          Default: http://localhost:6688
ETH_MIN_CONFIRMATIONS    Default: 12
ETH_GAS_BUMP_THRESHOLD   Default: 12
ETH_GAS_BUMP_WEI         Default: 5,000,000,000
ETH_GAS_PRICE_DEFAULT    Default: 20,000,000,000

Solidity Development setup

Before proceeding, make sure you have installed yarn

$ cd solidity
$ yarn install
$ truffle test

External Adapters

External adapters are added to the Chainlink node first by adding a bridge type. Bridge types define the name and URL of your external adapter. When a task type is received that is not one of the core adapters, the node will search for a bridge type with that name, creating a bridge to your external adapter.

bridge_type.json

{ "name": "randomNumber", "url": "http://localhost:3000/randomNumber" }

job.json

{
  "initiators": [{
    "type": "runLog",
    "address": "0x3cCad4715152693fE3BC4460591e3D3Fbd071b42"
  }],
  "tasks": [ {"type": "randomNumber"} ]
}

Adding an External Adapter

POST to /v2/bridge_types:

curl -u chainlink:twochains -X POST -H 'Content-Type: application/json' -d '{"name":"randomNumber","url":"http://localhost:3000/randomNumber"}' http://localhost:6688/v2/bridge_types

"name" should be unique to the local node, and "url" should be the URL of your external adapter, whether local or on a separate machine.

Output should return the JSON given:

{"name":"randomnumber","url":"https://example.com/randomNumber"}

And the node will log the following:

{"level":"info","ts":1518531822.179224,"caller":"web/router.go:50","msg":"Web request","method":"POST","status":200,"path":"/v2/bridge_types","query":"","body":"{\"name\":\"randomNumber\",\"url\":\"https://example.com/randomNumber\"}","clientIP":"127.0.0.1","comment":"","servedAt":"2018/02/13 - 14:23:42","latency":"1.623398ms"}

About

node of the decentralized oracle network, bridging on and off-chain computation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 71.0%
  • Solidity 18.3%
  • TypeScript 9.1%
  • Shell 0.8%
  • PLpgSQL 0.6%
  • Makefile 0.1%
  • Other 0.1%