'Chainlink example not updating value
I'm following the example within the Chainlink documentation (also below), and have been testing it within remix. I've deployed the contract on the kovan testnet & sent LINK to it, I'm able to execute the requestVolumeData() and get the notification that the transaction was completed and I'm able to view it on etherscan.
However, when checking the value of volume it always returns 0. I'm aware that it can take some time, but the value hasn't changed after waiting 20 minutes.
I've done tests with the following oracle addresses / job id's. From the example (0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8 & d5270d1c311941d0b08bead21fea7747) From the accompanying youtube video (0x2f90A6D021db21e1B2A077c5a37B3C7E75D15b7e & 29fa9aa13bf1468788b7cc4a500a45b8) And from chainlink market (set to kovan network). (0xA1d76ABD287d87d6E1d92262F7D53Cbe4f290505 & fc3ea215bb9e44e088107b29bb495e2d)
I'm not sure where things go wrong, I don't think it's the code since it's copy pasted from the example. But non of the adreses have worked.
pragma solidity ^0.8.7;
import "@chainlink/contracts/src/v0.8/ChainlinkClient.sol";
contract APIConsumer is ChainlinkClient {
using Chainlink for Chainlink.Request;
uint256 public volume;
address private oracle;
bytes32 private jobId;
uint256 private fee;
constructor() {
setPublicChainlinkToken();
oracle = 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8;
jobId = "d5270d1c311941d0b08bead21fea7747";
fee = 0.1 * 10 ** 18;
}
function requestVolumeData() public returns (bytes32 requestId) {
Chainlink.Request memory request = buildChainlinkRequest(jobId, address(this), this.fulfill.selector);
request.add("get", "https://min-api.cryptocompare.com/data/pricemultifull?fsyms=ETH&tsyms=USD");
request.add("path", "RAW.ETH.USD.VOLUME24HOUR");
int timesAmount = 10**18;
request.addInt("times", timesAmount);
return sendChainlinkRequestTo(oracle, request, fee);
}
function fulfill(bytes32 _requestId, uint256 _volume) public recordChainlinkFulfillment(_requestId) {
volume = _volume;
}
}
Solution 1:[1]
Line request.add("path", "RAW.ETH.USD.VOLUME24HOUR"); should be request.add("path", "RAW,ETH,USD,VOLUME24HOUR"); (notice the commas instead of dots).
Chainlink nodes 1.0.0 and later support this new "comma based" format. Chainlink nodes prior to 1.0.0 support the "dots based" format you provided in the original question.
From what I can see now, the official docs have been updated to include this change.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Andrej |
