this is my very first time deploying a contract on Remix as well as learning how to code on Solidity.
I have already read this guide and deployed successfully the Smart Contract template provided:
pragma solidity ^0.6.7;
import "@chainlink/contracts/src/v0.6/interfaces/AggregatorV3Interface.sol";
contract PriceConsumerV3 {
AggregatorV3Interface internal priceFeed;
/**
* Network: Kovan
* Aggregator: BTC/USD
* Address: 0x6135b13325bfC4B00278B4abC5e20bbce2D6580e
*/
constructor() public {
priceFeed = AggregatorV3Interface(0x6135b13325bfC4B00278B4abC5e20bbce2D6580e);
}
/**
* Returns the latest price
*/
function getThePrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return price;
}
}
However, I thought that after deploying the template above, whenever I clicked on the getLatestPrice button the price of such pair would get instantly updated, I was very wrong, the price actually turned out getting "frozen" after the first click.
So, I would like to know what would be mandatory to type in the template above to fulfill that aim
Also, I tried to print the timeStamp
by typing return timeStamp;
right below return price;
but when compiling, the Remix compiler replied:
TypeError: Return argument type uint256 is not implicitly convertible to expected type (type of first return variable) int256. return timeStamp; ^-------^
So, just for curiosity, how do I convert a uint256 variable to an int256 one in order to get the timeStamp of each updated price (for every time I click on getLatestPrice button
) ?
thanks for reading