Cyfrin / foundry-smart-contract-lottery-cu

47 stars 42 forks source link

Forge build error #67

Closed Tezei closed 1 day ago

Tezei commented 2 days ago

Hiya guys, When I tried forge build command I am getting error as follows:

[⠒] Compiling... [⠃] Compiling 2 files with Solc 0.8.19 [⠊] Solc 0.8.19 finished in 731.33ms Error: Compiler run failed: Error (9553): Invalid type for argument in function call. Invalid implicit conversion from literal_string "" to bytes calldata requested. --> src/Raffle.sol:161:45: 161 (bool upkeepNeeded, ) = checkUpkeep("");

Please, advise.

10x in advance

Equious commented 1 day ago

Comment out the required calldata in your checkUpkeep function like this:

function checkUpkeep(
        bytes memory /* checkData */
    ) public view returns (bool upkeepNeeded, bytes memory /*performData*/) {
        bool timeHasPassed = ((block.timestamp - s_lastTimeStamp) >=
            i_interval);
        bool isOpen = (s_lotteryState == LotteryState.OPEN);
        bool hasBalance = address(this).balance > 0;
        bool hasPlayers = s_entrants.length > 0;
        //this will return upkeepNeeded due to the explicit declaration in the return statement above
        upkeepNeeded = timeHasPassed && isOpen && hasBalance && hasPlayers;
        return (upkeepNeeded, "");
    }
Please use the Discussions tab for coding help, or join us in Discord!