chainlink

module
v1.3.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: MIT

README


Chainlink logo


GitHub tag (latest SemVer) GitHub license GitHub workflow changelog CircleCI build GitHub contributors GitHub commit activity Official documentation

Chainlink expands the capabilities of smart contracts by enabling access to real-world data and off-chain computation while maintaining the security and reliability guarantees inherent to blockchain technology.

This repo contains the Chainlink core node, operator UI and contracts. The core node is the bundled binary available to be run by node operators participating in a decentralized oracle network. All major release versions have pre-built docker images available for download from the Chainlink dockerhub. If you are interested in contributing please see our contribution guidelines. If you are here to report a bug or request a feature, please check currently open Issues. For more information about how to get started with Chainlink, check our official documentation. Resources for Solidity developers can be found in the Chainlink Hardhat Box.

Community

Chainlink has an active and ever growing community. Discord is the primary communication channel used for day to day communication, answering development questions, and aggregating Chainlink related content. Take a look at the community docs for more information regarding Chainlink social accounts, news, and networking.

  1. Install Go 1.17, and add your GOPATH's bin directory to your PATH
    • Example Path for macOS export PATH=$GOPATH/bin:$PATH & export GOPATH=/Users/$USER/go
  2. Install NodeJS & Yarn. See the current version in package.json at the root of this repo under the engines.node key.
    • It might be easier long term to use nvm to switch between node versions for different projects. For example, assuming $NODE_VERSION was set to a valid version of NodeJS, you could run: nvm install $NODE_VERSION && nvm use $NODE_VERSION
  3. Install Postgres (>= 11.x).
    • You should configure Postgres to use SSL connection (or for testing you can set ?sslmode=disable in your Postgres query string).
  4. Ensure you have Python 3 installed (this is required by solc-select which is needed to compile solidity contracts)
  5. Download Chainlink: git clone https://github.com/smartcontractkit/chainlink && cd chainlink
  6. Build and install Chainlink: make install
    • If you got any errors regarding locked yarn package, try running yarn install before this step
    • If yarn install throws a network connection error, try increasing the network timeout by running yarn install --network-timeout 150000 before this step
  7. Run the node: chainlink help

For the latest information on setting up a development environment, see the Development Setup Guide.

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:

We cannot recommend specific version numbers for ethereum nodes since the software is being continually updated, but you should usually try to run the latest version available.

NOTE: By default, chainlink will run in TLS mode. For local development you can disable this by setting the following env vars:

CHAINLINK_DEV=true
CHAINLINK_TLS_PORT=0
SECURE_COOKIES=false

Alternatively, you can 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. You should be able to access the UI at http://localhost:6688/.

Chainlink provides a remote CLI client as well as a UI. Once your node has started, you can open a new terminal window to use the CLI. You will need to log in to authorize the client first:

chainlink admin login

(You can also set ADMIN_CREDENTIALS_FILE=/path/to/credentials/file in future if you like, to avoid having to login again).

Now you can view your current jobs with:

chainlink jobs list

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

Check out the doc pages on Jobs to learn more about how to create Jobs.

Configuration

Node configuration is managed by a combination of environment variables and direct setting via API/UI/CLI.

Check the official documentation for more information on how to configure your node.

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.

Running tests

  1. Install Yarn

  2. Install gencodec and jq to be able to run go generate ./... and make abigen

  3. Install mockery

make mockery

Using the make command will install the correct version.

  1. Build contracts:
yarn
yarn setup:contracts
  1. Generate and compile static assets:
go generate ./...
  1. Prepare your development environment:
export DATABASE_URL=postgresql://127.0.0.1:5432/chainlink_test?sslmode=disable

Note: Other environment variables should not be set for all tests to pass

  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 ./...

Notes

  • The parallel flag can be used to limit CPU usage, for running tests in the background (-parallel=4) - the default is GOMAXPROCS
  • The p flag can be used to limit the number of packages tested concurrently, if they are interferring with one another (-p=1)
  • The -short flag skips tests which depend on the database, for quickly spot checking simpler tests in around one minute (you may still need a phony env var to pass some validation: DATABASE_URL=_test)

Solidity Development

Inside the contracts/ directory:

  1. Install dependencies:
yarn
  1. Run tests:
yarn test

Use of Go Generate

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

Nix Flake

A flake is provided for use with the Nix package manager. It defines a declarative, reproducible development environment.

To use it:

  1. Nix has to be installed with flake support.
  2. Run nix develop. You will be put in shell containing all the dependencies. Alternatively, a direnv integration exists to automatically change the environment when cd-ing into the folder.
  3. Create a local postgres database:
cd $PGDATA/
initdb
pg_ctl -l $PGDATA/postgres.log -o "--unix_socket_directories='$PWD'" start
createdb chainlink_test -h localhost
createuser --superuser --no-password chainlink -h localhost
  1. Start postgres, pg_ctl -l $PGDATA/postgres.log -o "--unix_socket_directories='$PWD'" start

Now you can run tests or compile code as usual.

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!

License

MIT

Directories

Path Synopsis
charts
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.
config
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.
internal/gethwrappers
Package gethwrappers provides infrastructure for generating and verifying go-ethereum wrapper packages for smart contracts.
Package gethwrappers provides infrastructure for generating and verifying go-ethereum wrapper packages for smart contracts.
internal/gethwrappers2
Package gethwrappers keeps track of the golang wrappers of the solidity contracts
Package gethwrappers keeps track of the golang wrappers of the solidity contracts
services
Package services contain the key components of the Chainlink node.
Package services contain the key components of the Chainlink node.
services/relay/types
Types are shared with external relay libraries so they can implement the interfaces required to run as a core OCR job.
Types are shared with external relay libraries so they can implement the interfaces required to run as a core OCR job.
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.
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.
utils
Package utils is used for common functions and tools used across the codebase.
Package utils is used for common functions and tools used across the codebase.
utils/big_math
Package bigmath compensates for awkward big.Int API.
Package bigmath compensates for awkward big.Int API.
web
web/schema
Package schema is used to read schema files go:generate go-bindata -ignore=\.go -pkg=schema -o=bindata.go ./...
Package schema is used to read schema files go:generate go-bindata -ignore=\.go -pkg=schema -o=bindata.go ./...
scripts Module
deployment module
e2e-tests module
tools

Jump to

Keyboard shortcuts

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