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

Random.org Chainlink (Testnet)

Chainlink has a dedicated connection to Random.org's API. This Chainlink will retrieve a single random number to return to your smart contract.

Steps for using this oracle

Chainlink Network Details

You will need to use the following LINK token address, oracle address, and Job ID in order to create the Chainlink request.

Ropsten

LINK Token address: 0x20fE562d797A42Dcb3399062AE9546cd06f63280
Oracle address: 0xc99B3D447826532722E41bc36e644ba3479E4365
JobID: 904c833b051a4547a62e3958691f79c0

Rinkeby

LINK token address: 0x01BE23585060835E02B77ef475b0Cc51aA1e0709
Oracle address: 0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e
JobID: b00ed7210563488cbe5a3b7729c0ec72

Kovan

LINK token address: 0xa36085F69e2889c224210F603D836748e7dC0088
Oracle address: 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e
JobID: e1ec38c3c1954095a3db716c4228031a

Create your Chainlinked contract

Import Chainlinked.sol into your contract so you can inherit the Chainlinked behavior.

pragma solidity ^0.4.24;

import "chainlink/contracts/ChainlinkClient.sol";

contract RandomOrgChainlink is ChainlinkClient {

  uint256 oraclePayment;

  constructor(uint256 _oraclePayment) public {
    setPublicChainlinkToken();
    oraclePayment = _oraclePayment;
  }
  // Additional functions here:
  
}

Tasks

Request Parameters

min

An optional minimum number to generate.

Solidity example

req.addUint("min", 100);

max

An optional maximum number to generate.

Solidity example

req.addUint("max", 1000);

Chainlink Examples

The example below can be used to send a Chainlink request for a random number.

function getRandom
(
  address _oracle,
  bytes32 _jobId
)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}

Here is an example of the fulfill method:

uint256 public data;

function fulfill(bytes32 _requestId, uint256 _data)
  public
  recordChainlinkFulfillment(_requestId)
{
  data = _data;
}

Random.org Chainlink (Testnet)


Suggested Edits are limited on API Reference Pages

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