LCX (Testnet)
This Chainlink has a dedicated connection to LCX's Cryptocurrency Reference Prices API. This service offers reliable daily reference prices of the U.S. dollar price and Euro price of one Bitcoin and one Ethereum.
Steps for using this oracle
- Write and deploy your Chainlink contract using the network details below
- Fund it with LINK (1 LINK is required per-request/)
- Call your request method
Network Details
You will need to use the following LINK token address, oracle address, and Job ID in order to create the Chainlink request.
Rinkeby
LINK Token address: 0x01BE23585060835E02B77ef475b0Cc51aA1e0709
Oracle address: 0x7AFe1118Ea78C1eae84ca8feE5C65Bc76CcF879e
JobID: eb3b27aac93e4bf68406f164b86b049e
Kovan
LINK Token address: 0xa36085F69e2889c224210F603D836748e7dC0088
Oracle address: 0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e
JobID: 81c63592d97a4485b1d1339b3578e07f
Create your contract
Import ChainlinkClient.sol into your contract so you can inherit the Chainlink behavior.
pragma solidity ^0.4.24;
import "@chainlink/contracts/src/v0.4/ChainlinkClient.sol";
contract LCXChainlink is ChainlinkClient {
uint256 oraclePayment;
constructor(uint256 _oraclePayment) public {
setPublicChainlinkToken();
oraclePayment = _oraclePayment;
}
// Additional functions here:
}
pragma solidity ^0.5.0;
import "@chainlink/contracts/src/v0.5/ChainlinkClient.sol";
contract LCXChainlink is ChainlinkClient {
uint256 oraclePayment;
constructor(uint256 _oraclePayment) public {
setPublicChainlinkToken();
oraclePayment = _oraclePayment;
}
// Additional functions here:
}
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/ChainlinkClient.sol";
contract LCXChainlink is ChainlinkClient {
uint256 oraclePayment;
constructor(uint256 _oraclePayment) public {
setPublicChainlinkToken();
oraclePayment = _oraclePayment;
}
// Additional functions here:
}
Tasks
Request Parameters
coin
Required
The symbol for the cryptocurrency.
Must be ETH or BTC
Solidity example
req.add("coin", "eth");
market
Required
The market currency symbol.
Must be USD or EUR
Solidity example
req.add("market", "usd");
Chainlink Examples
The examples below show how to create a request for the Chainlink node.
function requestPrice
(
address _oracle,
bytes32 _jobId,
string _coin,
string _market
)
public
onlyOwner
{
Chainlink.Request memory req = buildChainlinkRequest(_jobId, this, this.fulfill.selector);
req.add("coin", _coin);
req.add("market", _market);
req.addInt("times", 100);
sendChainlinkRequestTo(_oracle, req, oraclePayment);
}
Here is an example of the fulfill method:
uint256 public currentPrice;
function fulfill(bytes32 _requestId, uint256 _price)
public
recordChainlinkFulfillment(_requestId)
{
currentPrice = _price;
}