-
Please I don't know why the chainlink keepers is not looking out for checkUpkeep. Everything returns true but it does not call the perform upkeep |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
@ejim11 Please Provide more info (error and code). So we have a better understanding of you problem. |
Beta Was this translation helpful? Give feedback.
-
These are my checkUpkeep and performUpkeep functions. The code doesn't produce any error. chainlink keepers just fails to check the checkUpkeep function. function checkUpkeep(
bytes memory /*checkData*/
) public override returns (bool upkeepNeeded, bytes memory /* performData */) {
bool isOpen = RaffleState.OPEN == s_raffleState;
bool timePassed = (block.timestamp - s_lastTimeStamp) > i_interval;
bool hasPlayers = s_players.length > 0;
bool hasBalance = address(this).balance > 0;
upkeepNeeded = (isOpen && hasPlayers && hasBalance && timePassed);
return (upkeepNeeded, "0x0");
}
/**
*@dev This function is called by the chainlink keepers when upkeep is needed
*
*/
function performUpkeep(bytes memory /* performData */) external override {
// request random number
// Once we get it, do something with it
// 2 txns process
(bool upkeepNeeded, ) = checkUpkeep("");
if (!upkeepNeeded) {
revert Raffle__UpkeepNotNeeded(
address(this).balance,
s_players.length,
uint256(s_raffleState)
);
}
s_raffleState = RaffleState.CALCULATING;
uint256 requestId = i_vrfcoordinator.requestRandomWords(
i_gasLane, //gasLane
i_subscriptionId,
REQUEST_CORFIMATIONS,
i_callbackGasLimit,
NUM_WORDS
);
emit RequestedRaffleWinner(requestId);
} This is my deploy script module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = network.config.chainId
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("40")
let vrfCoordinatorV2Address, subscriptionId
if (developmentChains.includes(network.name)) {
const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
const transactionReceipt = await transactionResponse.wait(1)
subscriptionId = transactionReceipt.events[0].args.subId
// fund subscription
await vrfCoordinatorV2Mock.fundSubscription(subscriptionId, VRF_SUB_FUND_AMOUNT)
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"]
subscriptionId = networkConfig[chainId]["subscriptionId"]
}
const entranceFee = networkConfig[chainId]["entranceFee"]
const gasLane = networkConfig[chainId]["gasLane"]
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"]
const interval = networkConfig[chainId]["interval"]
const args = [
vrfCoordinatorV2Address,
entranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
interval,
]
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitConfirmations: network.config.blockConfirmations || 1,
})
if (!developmentChains.includes(network.name) && process.env.ETHERSCAN_KEY) {
log("Verifying......")
await verify(raffle.address, args)
}
log("----------------------------")
} And my hardhat-helper-config file const networkConfig = {
11155111: {
name: "sepolia",
vrfCoordinatorV2: "0x8103B0A8A00be2DDC778e6e7eaa21791Cd364625",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c",
subscriptionId: "2835",
callbackGasLimit: "500000000",
interval: 30,
},
31337: {
name: "hardhat",
entranceFee: ethers.utils.parseEther("0.01"),
gasLane: "0x474e34a077df58807dbe9c96d3c009b23b3c6d0cce433e59bbf5b34f823bc56c",
callbackGasLimit: "500000",
interval: "30",
},
} Incase I missed anything, pls you can show me. The contract deploys properly and everything works fine till i enter the raffle and the perform upkeep function is not called which is most likely due to the checkUpkeep not returning upkeepNeeded as true though it passes all the criterea. thank you. |
Beta Was this translation helpful? Give feedback.
-
@ejim11 |
Beta Was this translation helpful? Give feedback.
@ejim11
callBackGasLimit
is way too high, maximum forsepolia
is2,500,000
change it to500,000
in yourhardhat-helper-config
.and make sure other variables are properly initialized that are being used in request
requestRandomWords()