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

Binance Chainlink (Testnet)

This Chainlink has a dedicated connection to Binance's API. This Chainlink will allow requesters to create queries to the API, and return the response.

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
Bool JobID: f2b0f585c84a45d1993f8f3cb48ffb49
Bytes32 JobID: 1e322d70fce94991baa56e7151acddcf
Uint256 JobID: b8b8a31a3833434eba5bff70b203343d

Create your Chainlinked contract

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

pragma solidity ^0.4.24;

import "chainlink/contracts/ChainlinkClient.sol";

contract BinanceChainlink is ChainlinkClient {
  
  uint256 oraclePayment;

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

Tasks

Request Parameters

endpoint

Required

The endpoint of the api to call. Supported values are:

  • ping
  • time
  • avgPrice
    • symbol

Solidity example

req.add("endpoint", "avgPrice");

symbol

Used by the avgPrice endpoint. The symbol (pairing) to query.

Solidity example

req.add("symbol", "BNBUSDT");

copyPath

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

Solidity example

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

The response payload will vary depending on the endpoint used. Refer to the REST API docs for details.

times

Only valid for the Uint256 Job

The number to multiply the result by (since Solidity can't handle decimal places).

Solidity example

req.addInt("times", 100);

Chainlink Examples

The example below shows how to create requests for the adapter.

function getServerStatus(address _oracle, bytes32 _jobId)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfillStatus.selector);
  req.add("endpoint", "ping");
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}
function getAvgPrice(address _oracle, bytes32 _jobId, string _symbol)
  public
  onlyOwner
{
  Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfillPrice.selector);
  req.add("endpoint", "avgPrice");
  req.add("symbol", _symbol);
  req.add("copyPath", "price");
  req.addInt("times", 100);
  sendChainlinkRequestTo(_oracle, req, oraclePayment);
}

Here is an example of the fulfill methods:

event ServerStatus(bool _status);

function fulfillStatus(bytes32 _requestId, bool _status)
  public
  recordChainlinkFulfillment(_requestId)
{
  emit ServerStatus(_status);
}
event CurrentPrice(uint256 _price);

function fulfillPrice(bytes32 _requestId, uint256 _price)
  public
  recordChainlinkFulfillment(_requestId)
{
  emit CurrentPrice(_price);
}

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