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

Fulfilling Requests

With your own Oracle contract, you can use your own node to fulfill requests. This guide will show you how to deploy your own Oracle contract and add jobs to your node so that it can provide data to smart contracts.

Prerequisites

Deploy your own Oracle contract

  • Go to Remix and expand the gist menu
  • Click on Oracle.sol. The contents of this file will be very minimal, since we only need to import the code hosted on Github.
  • On the Compile tab, click on the "Start to compile" button near the top-right
  • Change to the Run tab
  • Select Oracle from the drop-down in the right panel
  • Copy the line below for your network and paste it into the text field next to the Deploy button
0x20fE562d797A42Dcb3399062AE9546cd06f63280
0x01BE23585060835E02B77ef475b0Cc51aA1e0709
0xa36085F69e2889c224210F603D836748e7dC0088
0x514910771AF9Ca656af840dff83E8264EcF986CA
  • Click Deploy

Metamask will prompt you to Confirm the Transaction

Metamask doesn't pop up?

If Metamask does not prompt you and instead displays the error below, you will need to disable "Privacy Mode" in Metamask. You can do this by clicking on your unique account icon at the top-right, then go to the Settings. Privacy Mode will be a switch near the bottom.
 
The error:

Send transaction failed: invalid address . if you use an injected provider, please check it is properly unlocked.

A link to Etherscan will display at the bottom, you can open that in a new tab to keep track of the transaction

Once successful, you should have a new address for the deployed contract

Keep note of the Oracle contract's address, you will need it for your consuming contract later.

Add your node to the Oracle contract

  • In Remix, call the setFulfillmentPermission function with the address of your node, a comma, and the value true, as the input parameters.

This will allow your node the ability to fulfill requests to your oracle contract.

You can get the address of your node when it starts or by visiting the Configuration page of the GUI.

Once you call the setFulfillmentPermission function, Confirm it in Metamask and wait for it to confirm on the blockchain.

Add jobs to the node

Adding jobs to the node is easily accomplished via the GUI. We have example Job Specifications below.

Replace YOUR_ORACLE_CONTRACT_ADDRESS below with the address of your deployed oracle contract address from the previous steps. Note that this is different than the ACCOUNT_ADDRESS from your node.

{
  "initiators": [
    {
      "type": "runlog",
      "params": {
        "address": "YOUR_ORACLE_CONTRACT_ADDRESS"
      }
    }
  ],
  "tasks": [
    {
      "type": "httpget"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "ethbytes32"
    },
    {
      "type": "ethtx"
    }
  ]
}
{
  "initiators": [
    {
      "type": "runlog",
      "params": {
        "address": "YOUR_ORACLE_CONTRACT_ADDRESS"
      }
    }
  ],
  "tasks": [
    {
      "type": "httppost"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "ethbytes32"
    },
    {
      "type": "ethtx"
    }
  ]
}
{
  "initiators": [
    {
      "type": "runlog",
      "params": {
        "address": "YOUR_ORACLE_CONTRACT_ADDRESS"
      }
    }
  ],
  "tasks": [
    {
      "type": "httpget"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "multiply"
    },
    {
      "type": "ethint256"
    },
    {
      "type": "ethtx"
    }
  ]
}
{
  "initiators": [
    {
      "type": "runlog",
      "params": {
        "address": "YOUR_ORACLE_CONTRACT_ADDRESS"
      }
    }
  ],
  "tasks": [
    {
      "type": "httpget"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "multiply"
    },
    {
      "type": "ethuint256"
    },
    {
      "type": "ethtx"
    }
  ]
}
{
  "initiators": [
    {
      "type": "runlog",
      "params": {
        "address": "YOUR_ORACLE_CONTRACT_ADDRESS"
      }
    }
  ],
  "tasks": [
    {
      "type": "httpget"
    },
    {
      "type": "jsonparse"
    },
    {
      "type": "ethbool"
    },
    {
      "type": "ethtx"
    }
  ]
}
  • From the admin dashboard, click on New Job.
  • Paste the job from above into the text field.
  • Click Create Job and you'll be notified of the new JobID creation.

Take note of this JobID as you'll need it later.

  • Repeat this process for each of the jobs above.

The address for the jobs will auto-populate with the zero-address. This means the Chainlink node will listen to your Job ID from any address. You can also specify an address in the params object of the RunLog initiator for your oracle contract.

Create a request to your node

If you're going through this guide on Ethereum mainnet, the TestnetConsumer.sol contract will still work. However, understand that you're sending real LINK to yourself. Be sure to practice on the test networks multiple times before attempting to run a node on mainnet.

With the jobs added, you can now use your node to fulfill requests. This last section shows what requesters will do when they send requests to your node. It is also a way to test and make sure that your node is functioning correctly.

  • In Remix, create a new file named TestnetConsumer.sol and copy and paste the TestnetConsumer.sol contract into it.

  • Click "Start to compile".

The contract should compile.

You can now deploy it and fund it by sending some LINK to its address. See the Fund your contract. page for instructions on how to do that.

  • To create a request, input your oracle contract address and the JobID for the EthUint256 job into the requestEthereumPrice request method, separated by a comma.
  • Click the request method button and you should see your node log the request coming in and its fulfillment.

Once the transaction from the node is confirmed, you should see the value updated on your contract by clicking on the currentPrice button.

Fulfilling Requests


Suggested Edits are limited on API Reference Pages

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