0

Like the title says, it seems all the conditions for a keeper to run performUpkeep have been met, yet it is not being called.

I have verify my smart contract, make it Kepper Compatible, Fund the Keeper with sufficient LINK.

Here is the upkeep link: https://keepers.chain.link/mumbai/1560

Here is the contract: https://mumbai.polygonscan.com/address/0x5BdfE445c664020988f857b42E6772385da0EdB6#code

Here is the relevant code:

 function checkUpkeep(
        bytes memory /* checkData */
    )
        public
        view
        override
        returns (
            bool upkeepNeeded,
            bytes memory /* performData */
        )
    {
        bool timePassed = ((block.timestamp - lastTimeStamp) > interval); // keep track of betting
        bool hasPlayers = upBetAddresses.length > 0 ||
            downBetAddresses.length > 0;
        upkeepNeeded = (timePassed && hasPlayers);
        return (upkeepNeeded, "0x0");
    }

    // function to send MATIC to the winners
    function performUpkeep(
        bytes calldata /* performData */
    ) external override {
        // this is the way to get checkUpKeep function. we only need 1 parameter, therefore (bool upkeepNeede, ) next is blank.
        (bool upkeepNeeded, ) = checkUpkeep("");
        if (!upkeepNeeded) {
            revert BET_UPKEEP_NOT_NEEDED();
        }
        //We highly recommend revalidating the upkeep in the performUpkeep function
        if ((block.timestamp - lastTimeStamp) > interval) {
            executePlaceBet();
            lastTimeStamp = block.timestamp;
        }
        emit Perform_UpKeep();
    }

    // placing bet with simple up and down
    function executePlaceBet() private {
     //code
    }

Use Hardhat to deploy code. Some relevant code:

const deployedVerifyContract = await verifyContract.deploy(INTERVAL, FEE);

Create index.js for constants

const FEE = ethers.utils.parseEther("1");
const INTERVAL = 3600;

Upkeep when 1 hour have passed and there are players in array / dapp enter image description here

4
  • Could you add what your checkupkeep and performupkeep are returning? Also it might be easier to keep the time interval smaller - I called perforumUpkeep just to see if it would go through, and it did - but now we have to wait 3600 seconds May 24 at 11:53
  • I want checkUpKeep to wait for 1 hour and check the players in betting and if condition is true then execute performUpKeep. I need to do it every hour because Data feed of ETH/USD changes every hour. There is no logic for PerformUpKeep to wait for another 1 hour / 3600 seconds before executing. May 24 at 13:47
  • Looks like it's working now. I'm willing to bet it's the Mumbai testnet having issues - I always recommend not using a polygon testnet. May 24 at 13:52
  • I am creating the this project for chainlink Hackathon. They suggested to use L2 solution to create project. Can you please check again. The thing is, I have updated my smart contract to add some functions. I have manually execute performUpKeep and it performing all the functions. But now keeper stop working for new Contract. May 24 at 16:35

2 Answers 2

0

It looks like your gas limit may be too low. I simulated the transaction and it looks like it would use 169,872 gas. Your gas limit is 50,000. I'd recommend recreating the upkeep with some buffer. Maybe with a gas limit of 300,000 to be safe?

0

Hey Ayush

I wasn't able to replicate your issue. I took the verified version of your contract and changed interval to 60 seconds. It's deployed here (unverified) and the events are here.

I also registered it as an upkeep

As long as a bet is placed, it works. You can see from the History on my upkeep that performUpkeep gets called. You can also see the bets I placed in the the etherscan link I linked to above.

My test account's transactions are here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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