I wanted to pull the historical data stored by the reference data contracts by chainlink oracles. Since all the data is on-chain, I should be able to view it all? But currently, my contract can only see the latest answer. Any thoughts?
pragma solidity ^0.6.0;
import "@chainlink/contracts/src/v0.6/dev/AggregatorInterface.sol";
contract ReferenceConsumer {
AggregatorInterface internal ref;
constructor(address _aggregator) public {
ref = AggregatorInterface(_aggregator);
}
function getLatestAnswer() public returns (int256) {
return ref.latestAnswer();
}
}
Best Answer
You can view the entire history of reference contracts, you'll want to use the
getPreviousAnswer
method below, and input how many answers back you'd like to go.