Chainlink Developers

Welcome to the Chainlink documentation site. You'll find comprehensive guides and documentation to help you start working with Chainlink as quickly as possible, as well as support if you get stuck. Click here for an introductory walkthrough on how to create a Chainlink request on the Ropsten test network!

Building on Chainlink? Click here to get started!

Get Started

Create a Chainlinked Project

Once you've determined that you want to use the Chainlink Library to create a ChainlinkClient contract, you can then proceed to creating a new Chainlink project or updating an existing one. In this section, we'll explain everything you need to know on how to do so.

Creating a new Chainlinked project

Using Truffle, it's very easy to get started creating Chainlinked contracts from a template. Simply run the command below to unbox a Chainlinked contract in your current directory.

truffle unbox smartcontractkit/box

For more details on how to use the Truffle Box, see this blog post.

Add Chainlink to your existing project

If you already have a project started, you can add Chainlink to it by running one of the following commands.

With NPM:

npm install @chainlink/contracts --save

With Yarn:

yarn add @chainlink/contracts

If you are using OpenZeppelin Starter Kits, you can create a new project by running:

oz unpack smartcontractkit/box

Create your Chainlinked contract

Import ChainlinkClient.sol into your contract so you can inherit the behavior to create Chainlink requests.

pragma solidity ^0.4.24;

import "@chainlink/contracts/src/v0.4/ChainlinkClient.sol";

// MyContract inherits the Chainlinked contract to gain the
// functionality of creating Chainlink requests.
contract MyContract is ChainlinkClient {
  constructor(address _link) public {
    // Set the address for the LINK token for the network.
    if(_link == address(0)) {
      // Useful for deploying to public networks.
      setPublicChainlinkToken();
    } else {
      // Useful if you're deploying to a local network.
      setChainlinkToken(_link);
    }
  }
  // Additional functions here:
  
}
pragma solidity ^0.5.0;

import "@chainlink/contracts/src/v0.5/ChainlinkClient.sol";

// MyContract inherits the Chainlinked contract to gain the
// functionality of creating Chainlink requests.
contract MyContract is ChainlinkClient {
  constructor(address _link) public {
    // Set the address for the LINK token for the network.
    if(_link == address(0)) {
      // Useful for deploying to public networks.
      setPublicChainlinkToken();
    } else {
      // Useful if you're deploying to a local network.
      setChainlinkToken(_link);
    }
  }
  // Additional functions here:
  
}
pragma solidity ^0.6.0;

import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";

// MyContract inherits the Chainlinked contract to gain the
// functionality of creating Chainlink requests.
contract MyContract is ChainlinkClient {
  constructor(address _link) public {
    // Set the address for the LINK token for the network.
    if(_link == address(0)) {
      // Useful for deploying to public networks.
      setPublicChainlinkToken();
    } else {
      // Useful if you're deploying to a local network.
      setChainlinkToken(_link);
    }
  }
  // Additional functions here:
  
}

Updated 24 days ago


What's Next

Learn how to request and receive data with your new Chainlinked project.

Request & Receive Data

Create a Chainlinked Project


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.