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.
- 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.
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.
- Install Go 1.15, and add your GOPATH's bin directory to your PATH
- Example Path for macOS
export PATH=$GOPATH/bin:$PATH
&export GOPATH=/Users/$USER/go
- Example Path for macOS
- Install NodeJS 12.18 & Yarn
- It might be easier long term to use nvm to switch between node versions for different projects:
nvm install 12.18 && nvm use 12.18
- It might be easier long term to use nvm to switch between node versions for different projects:
- Install Postgres (>= 11.x).
- You should configure Postgres to use SSL connection
- Download Chainlink:
git clone https://github.com/smartcontractkit/chainlink && cd chainlink
- 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 runningyarn install --network-timeout 150000
before this step
- If you got any errors regarding locked yarn package, try running
- Run the node:
chainlink help
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:
- Parity 1.11+ (due to a fix with pubsub.)
- Geth 1.8+
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 job_specs list # v1 jobs
chainlink jobs list # v2 jobs
View details of a specific job with:
chainlink job_specs show "$JOB_ID # v1 jobs"
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.
You can configure your node's behavior by setting environment variables. All the environment variables can be found in the ConfigSchema
struct of schema.go
. You can also read the official documentation to learn the most up to date information on each of them. For every variable, default values get used if no corresponding environment variable is found.
Chainlink is a monorepo containing several logically separatable and relatable projects.
- core - the core Chainlink node
- @chainlink/belt - tools for performing commands on Chainlink smart contracts
- @chainlink/contracts - smart contracts
- @chainlink/test-helpers - smart contract-related resources
- integration/forks - integration test for ommers and re-orgs
- tools - Chainlink tools
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.
For the latest information on setting up a development environment, see the guide here.
go build -o chainlink ./core/
- Run the binary:
./chainlink
-
Install gencodec, mockery version 1.0.0, and jq to be able to run
go generate ./...
andmake abigen
-
Build contracts:
yarn
yarn setup:contracts
- Generate and compile static assets:
go generate ./...
go run ./packr/main.go ./core/services/eth/
- 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
- 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
- Run tests:
go test -parallel=1 ./...
Note:
evm-contracts/
directory houses Solidity versions <=0.7. New contracts, using v0.8, are being developed in thecontracts/
directory, using hardhat.
Inside the evm-contracts/
directory:
- Install Yarn
- Install the dependencies:
yarn
yarn setup
-
Run tests:
i. Solidity versions
0.4.x
to0.7.x
:yarn test
Inside the contracts/
directory:
- Install dependencies:
yarn
- Run tests:
yarn test
Go generate is used to generate mocks in this project. Mocks are generated with mockery and live in core/internal/mocks.
A flake is provided for use with the Nix package manager. It defines a declarative, reproducible development environment.
To use it:
- Nix has to be installed with flake support.
- Run
nix develop
. You will be put in shell containing all the dependencies. Alternatively, adirenv
integration exists to automatically change the environment whencd
-ing into the folder. - 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
- Start postgres,
pg_ctl -l $PGDATA/postgres.log -o "--unix_socket_directories='$PWD'" start
Now you can run tests or compile code as usual.
For more tips on how to build and test Chainlink, see our development tips page.
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!