chainlink

module
v0.8.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2020 License: MIT

README

CircleCI Go Report Card GoDoc Maintainability Test Coverage

Chainlink is middleware to simplify communication with blockchains. Here you'll find the Chainlink Golang node, currently in alpha. This initial implementation is intended for use and review by developers, and will go on to form the basis for Chainlink's decentralized oracle network. Further development of the Chainlink Node and Chainlink Network will happen here, if you are interested in contributing please see our contribution guidelines. The current node supports:

  • easy connectivity of on-chain contracts to any off-chain computation or API
  • multiple methods for scheduling both on-chain and off-chain computation for a user's smart contract
  • automatic gas price bumping to prevent stuck transactions, assuring your data is delivered in a timely manner
  • push notification of smart contract state changes to off-chain systems, by tracking Ethereum logs
  • translation of various off-chain data types into EVM consumable types and transactions
  • easy to implement smart contract libraries for connecting smart contracts directly to their preferred oracles
  • easy to install node, which runs natively across operating systems, blazingly fast, and with a low memory footprint

Examples of how to utilize and integrate Chainlinks can be found in the Chainlink Truffle Box.

Install

  1. Install Go 1.14, and add your GOPATH's bin directory to your PATH
  2. Install NodeJS & Yarn
  3. Install Postgres (>= 9.6).
  4. Download Chainlink: git clone https://github.com/smartcontractkit/chainlink && cd chainlink
  5. Build and install Chainlink: make install
  6. Run the node: chainlink help
Ethereum Node Requirements

In order to run the Chainlink node you must have access to a running Ethereum node with an open websocket connection. Any Ethereum based network will work once you've configured the chain ID. Ethereum node versions currently tested and supported:

Run

NOTE: By default, chainlink will run in TLS mode. For local development you can either disable this by setting CHAINLINK_DEV to true, or generate self signed certificates using tools/bin/self-signed-certs or manually.

To start your Chainlink node, simply run:

chainlink node start

By default this will start on port 6688, where it exposes a REST API.

Once your node has started, you can view your current jobs with:

chainlink jobs list

View details of a specific job with:

chainlink jobs show "$JOB_ID"

To find out more about the Chainlink CLI, you can always run chainlink help.

Check out the docs' pages on Adapters and Initiators to learn more about how to create Jobs and Runs.

Configure

You can configure your node's behavior by setting environment variables which can be, along with default values that get used if no corresponding environment variable is found. The latest information on configuration variables are available in the docs.

Project Directory

This project contains several sub-projects, some with their own documentation.

External Adapters

External adapters are what make Chainlink easily extensible, providing simple integration of custom computations and specialized APIs. A Chainlink node communicates with external adapters via a simple REST API.

For more information on creating and using external adapters, please see our external adapters page.

Development Setup

For the latest information on setting up a development environment, see the guide here.

Build your current version
go build -o chainlink ./core/
  • Run the binary:
./chainlink
Test Core
  1. Install Yarn

  2. Build contracts:

yarn
yarn setup:contracts
  1. Generate and compile static assets:
go generate ./...
go run ./packr/main.go ./core/eth/
  1. Prepare your development environment:
export DATABASE_URL=postgresql://127.0.0.1:5432/chainlink_test?sslmode=disable
export CHAINLINK_DEV=true # I prefer to use direnv and skip this
  1. Drop/Create test database and run migrations:
go run ./core/main.go local db preparetest

If you do end up modifying the migrations for the database, you will need to rerun

  1. Run tests:
go test -parallel=1 ./...
Solidity Development
  1. Install Yarn
  2. Install the dependencies:
cd evm
yarn install
  1. Run tests:
yarn run test-sol
Use of Go Generate

Go generate is used to generate mocks in this project. Mocks are generate with mockery and live in core/internal/mocks.

Development Tips

For more tips on how to build and test Chainlink, see our development tips page.

Contributing

Chainlink's source code is licensed under the MIT License, and contributions are welcome.

Please check out our contributing guidelines for more details.

Thank you!

Directories

Path Synopsis
adapters
Package adapters contain the core adapters used by the Chainlink node.
Package adapters contain the core adapters used by the Chainlink node.
cmd
Package cmd is the front-end interface for the application as a command-line utility.
Package cmd is the front-end interface for the application as a command-line utility.
logger
Package logger is used to store details of events in the node.
Package logger is used to store details of events in the node.
services
Package services contain the key components of the Chainlink node.
Package services contain the key components of the Chainlink node.
services/signatures/cryptotest
package cryptotest provides convenience functions for kyber-based APIs.
package cryptotest provides convenience functions for kyber-based APIs.
services/signatures/ethdss
Package ethdss implements the Distributed Schnorr Signature protocol from the ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package ethdss implements the Distributed Schnorr Signature protocol from the ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
services/signatures/ethschnorr
Package ethschnorr implements a version of the Schnorr signature which is ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package ethschnorr implements a version of the Schnorr signature which is ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
services/signatures/secp256k1
Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} ////////////////////////////////////////////////////////////////////////////// XXX: Do not use in production until this code has been audited.
services/vrf
Numbers are deterministically generated from seeds and a secret key, and are statistically indistinguishable from uniform sampling from {0,...,2**256-1}, to computationally-bounded observers who know the seeds, don't know the key, and only see the generated numbers.
Numbers are deterministically generated from seeds and a secret key, and are statistically indistinguishable from uniform sampling from {0,...,2**256-1}, to computationally-bounded observers who know the seeds, don't know the key, and only see the generated numbers.
store
Package store is used to keep application events in sync between the database on the node and the blockchain.
Package store is used to keep application events in sync between the database on the node and the blockchain.
store/models
Package models contain the key job components used by the Chainlink application.
Package models contain the key job components used by the Chainlink application.
store/models/vrfkey
Package vrfkey tracks the secret keys associated with VRF proofs.
Package vrfkey tracks the secret keys associated with VRF proofs.
store/presenters
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
Package presenters allow for the specification and result of a Job, its associated TaskSpecs, and every JobRun and TaskRun to be returned in a user friendly human readable format.
utils
Package utils is used for the common functions for dealing with conversion to and from hex, bytes, and strings, formatting time.
Package utils is used for the common functions for dealing with conversion to and from hex, bytes, and strings, formatting time.
web
Package web handles receiving and supplying information within the node.
Package web handles receiving and supplying information within the node.
scripts Module
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL