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

Streamr Chainlink (Testnet)

Chainlink has a dedicated connection to Streamr's API. This Chainlink will retrieve the latest entry for a given stream 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
Bytes32 JobID: 1216278fa01449f99ad63bf1a813741f
Int256 JobID: d44b63ca23684b67aab07f1fce4753ec
Uint256 JobID: 8c8c6eaf33fc4635a4cf095c40a91d67

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 StreamrChainlink is ChainlinkClient {

  uint256 oraclePayment;

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

Tasks

Bytes32 JobID:

EthInt256 JobID:

EthUint256 JobID:

Request Parameters

stream

Required

The ID of the stream to retrieve the data.

Solidity example

req.add("stream", "kXSC3EtJSw2qECh9EBSeag");

partition

The partition of the stream.

Defaults to 0 if unset

Solidity example

req.addInt("partition", 1);

copyPath

Required

The path of the desired data field to return to the smart contract.

Solidity example

req.add("copyPath", "renewables");

Chainlink Examples

The example below can be used to send a Chainlink request for a given stream that returns a uint256 data type.

function getData
(
  address _oracle,
  bytes32 _jobId,
  string _stream,
  string _path
)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
  req.add("stream", _stream);
  req.add("copyPath", _path);
  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;
}

Updated 12 months ago

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