What is the purpose of checkUpKeep()
and performUpKeep()
#6720
Replies: 2 comments 6 replies
-
So here the point is that we are using ChainLink keepers to upkeep our Smart contract right . So for these keepers to work our contract have to compatible with theirs , so when you check the documentation , we can see that , Chainlink keepers work on the basis of these two functions |
Beta Was this translation helpful? Give feedback.
-
In the context of blockchain-based smart contracts, particularly when using Chainlink Keepers (now Chainlink Automation), the functions checkUpkeep() and performUpkeep() play crucial roles in automating certain contract functions. checkUpkeep(): This function is called by the Chainlink Keeper nodes to determine whether the contract requires any upkeep or maintenance. It returns a boolean value indicating if the conditions for upkeep are met. If checkUpkeep() returns true, it means that the conditions have been satisfied and performUpkeep() should be executed. performUpkeep(): If checkUpkeep() indicates that upkeep is needed, performUpkeep() is called by the Keeper nodes. This function contains the logic for the actual tasks that need to be performed, such as executing specific contract functions, updating states, or triggering actions. Together, these functions allow for the decentralized and automated execution of smart contract tasks without requiring manual intervention. |
Beta Was this translation helpful? Give feedback.
-
`//SPDX License-Identifier: MIT;
pragma solidity ^0.8.20;
import {VRFConsumerBaseV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol";
import "@chainlink/contracts/src/v0.8/vrf/interfaces/VRFCoordinatorV2Interface.sol";
import {AutomationCompatibleInterface} from "@chainlink/contracts/src/v0.8/automation/AutomationCompatible.sol";
// 1. Enter Raffle
// 2. Pick a random winner - Chainlink VRF
// 3. In every X minutes - Chainlink automation
error Raffle__NotEnoughETH();
error Raffle__RaffleNotOpened();
error Raffle__TransferFailed();
error Raffle__upKeepNotNeeded();
contract Raffle is VRFConsumerBaseV2Plus, AutomationCompatibleInterface, {
// State Varables
enum RaffleState {
OPEN,
CALCULATING
}
}
`
Beta Was this translation helpful? Give feedback.
All reactions