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

RTrade Chainlink (Testnet)

This Chainlink has a dedicated connection to RTrade's Temporal API. This Chainlink's functionality is currently limited to retrieving information about the public IPFS network.

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: 21c0830129cc498f9646941718bd29a2

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

  uint256 oraclePayment;

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

Tasks

Request Parameters

action

Required

Current supported actions:

  • stat
    Used to retrieve the object statistics for a content hash
  • dag
    Retrieves the associated IPLD object for a given cid

Solidity example

req.add("action", "stat");

hash

Required

The IPFS hash.

Solidity example

req.add("hash", "QmZpTc2UXsDeiD4Fb6j1kHqMeBngrN6V4myWR28i1YfuYA");

copyPath

Required

The path of the desired data field to return to the smart contract. Examples of returned data format for their given actions are below:

{
	"code": 200,
	"response": {
		"Hash": "QmZpTc2UXsDeiD4Fb6j1kHqMeBngrN6V4myWR28i1YfuYA",
		"BlockSize": 498,
		"CumulativeSize": 13673755,
		"DataSize": 2,
		"LinksSize": 496,
		"NumLinks": 10
	}
}
{
	"code": 200,
	"response": {
		"data": "CAE=",
		"links": [
			{
				"Cid": {
					"/": "QmSMMHB9QVEC37ie7G2FcekKLn5wFySie9XoMwEWkDwJBS"
				},
				"Name": "404.html",
				"Size": 4561
			},
			/* ... */
		]
	}
}

Solidity example

req.add("copyPath", "response.CumulativeSize");

Chainlink Examples

The example below will get you the cumulative size of a given IPFS hash.

function getIpfsSize
(
  address _oracle,
  bytes32 _jobId,
  string _hash
)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
  req.add("action", "stat");
  req.add("hash", _hash);
  req.add("copyPath", "response.CumulativeSize");
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}

Here is an example of the fulfill method:

bytes32 public data;

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

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