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

Make an Existing Job Request

🚧

Ropsten Testnet

The Ropsten Ethereum testnet is currently experiencing some issues. As such, this Ropsten example may not function as expected.

Using an existing Oracle Job makes your smart contract code more succinct. This page explains how to make an HTTP GET request to the ETH-USD Price endpoint in the CoinGecko API, to retrieve the price of ETH, using an existing Oracle job.

Coin Gecko Consumer

In Make a GET Request, the example contract code declared which URL to hit, where to find the data in the response, and how to convert it so that it can be represented on-chain.

In this example, an Oracle Job was found on Chainlink Market that is pre-configured to perform these tasks. This means that our contract needn't specify them itself, it only needs the Oracle address and the Job ID.

This example uses the Omniscience Ropsten Oracle, which runs the ETH-USD CoinGecko Job.

The contract should own enough LINK to pay the specified fee.

pragma solidity ^0.6.0;

import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";

contract CoinGeckoConsumer is ChainlinkClient {
    address private oracle;
    bytes32 private jobId;
    uint256 private fee;
    
    uint256 public ethereumPrice;
    
    /**
     * Network: Ropsten
     * Oracle: 
     *      Name:           Omniscience Ropsten
     *      Listing URL:    https://market.link/nodes/57587577-8ded-4d56-bb89-14da301e71cb
     *      Address:        0x83dA1beEb89Ffaf56d0B7C50aFB0A66Fb4DF8cB1
     * Job: 
     *      Name:           ETH-USD CoinGecko
     *      Listing URL:    https://market.link/jobs/d630df4f-1ed1-449b-8c0b-c27ab7a581a2
     *      ID:             93547cb3c6784ec08a366be6211caa24
     *      Fee:            0.1 LINK
     */
    constructor() public {
        setPublicChainlinkToken();
        oracle = 0x83dA1beEb89Ffaf56d0B7C50aFB0A66Fb4DF8cB1; // oracle address
        jobId = "93547cb3c6784ec08a366be6211caa24"; //job id
        fee = 0.1 * 10 ** 18; // 0.1 LINK
    }
    
    /**
     * Make initial request
     */
    function requestEthereumPrice() public {
        Chainlink.Request memory req = buildChainlinkRequest(jobId, address(this), this.fulfillEthereumPrice.selector);
        sendChainlinkRequestTo(oracle, req, fee);
    }
    
    /**
     * Callback function
     */
    function fulfillEthereumPrice(bytes32 _requestId, uint256 _price) public recordChainlinkFulfillment(_requestId) {
        ethereumPrice = _price;
    }
}

For more information on finding existing jobs, see Finding Existing Jobs.

Updated 13 days ago

Make an Existing Job Request


Suggested Edits are limited on API Reference Pages

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