Reputation: 463
I am trying to use the keepers chainlink service to get the eth/usd on the Kovan test net. I deployed my contract and registered it with keepers and funded with link token. Still I am not seeing the getLatestPrice() update.
contract address: 0xA29196C270cC15cb5D758Ae3613285720e6DEEb9 Upkeep address: 0xA29196C270cC15cb5D758Ae3613285720e6DEEb9
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
interface KeeperCompatibleInterface {
function checkUpkeep(bytes calldata checkData) external returns (bool upkeepNeeded, bytes memory performData);
function performUpkeep(bytes calldata performData) external;
}
contract Counter is KeeperCompatibleInterface {
AggregatorV3Interface internal priceFeed;
uint public counter; // Public counter variable
// Use an interval in seconds and a timestamp to slow execution of Upkeep
uint public immutable interval;
uint public lastTimeStamp;
constructor(uint updateInterval) {
interval = updateInterval;
lastTimeStamp = block.timestamp;
counter = 0;
priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
}
function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return price;
}
function checkUpkeep(bytes calldata checkData) external view override returns (bool upkeepNeeded, bytes memory performData) {
upkeepNeeded = (block.timestamp - lastTimeStamp) > interval;
performData = checkData;
}
function performUpkeep(bytes calldata performData) external override {
lastTimeStamp = block.timestamp;
counter = counter + 1;
performData;
getLatestPrice();
}
}
Upvotes: 0
Views: 122
Reputation: 856
your upkeep job would be getting called, but the problem is you're not doing anything with the getLatestPrice function. This is a view function that just returns the current feed price. If you were to add a line in your performUpkeep function to actually store the result of getLatestPrice() in a variable in the contract, then you would see that it is getting called
Upvotes: 1