0

I have a mapping(uint256 => uint256) projectTime which I use to map every projectId to its time trigger. I want to trigger every project when its time is met. Let's say projectId = 1 will be triggered after 1 day, projectId = 2 will be triggered after 7 days, based on this mapping. Do I have to register every project? Or is there a better way to do this?

1 Answer 1

1

If I understand your question correctly, no.

In the checkUpkeep function you would check each projectId and test whether it should be triggered or not. This work is performed off-chain by the keeper network. You then pass the projectIds that should be triggered to performUpkeep by returning them in performData.

In performUpkeep, you re-test the projectIds that you passed in performData from checkUpkeep, otherwise there's nothing to prevent someone else triggering any projectId at any time.

2
  • can i use check upkeep like this or do i have use some for loop for this function checkUpkeep( bytes memory /* checkData / ) public view override returns ( bool upkeepNeeded, bytes memory / performData */ ) { bool isFunded = _isFunding[projectId]; bool timePassed = (block.timestamp - (projectToTime[projectId][time[projectId]])) > time[projectId]; upkeepNeeded = (isFunded); } Commented Nov 10, 2022 at 6:18
  • sorry. i ask bad question get wrong answer :) Please kindly check the link. But not the question i give the second answer on page below. That is i think a solution what i want tot do. Also what you suggest. ethereum.stackexchange.com/questions/139132/… Commented Nov 10, 2022 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.