I am trying to implement the chainlink keeper to my contract. Actually I want to use the function checkUpkeep that is defined in this way:

function checkUpKeep(bytes calldata /* */) public returns (bool /* */, bytes memory /* */)

When I try to call this function with the literal string " " as parameter, solidity compiler (0.8.8) throw me this error:

TypeError: Invalid type for argument in function call. Invalid implicit conversion from literal_string "" to bytes calldata requested.

I call this function in this way:


My code:

function checkUpkeep(bytes calldata /* 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 && timePassed && hasPlayers && hasBalance);

    function performUpkeep(bytes calldata /* performData */) external override{
        (bool upkeepNeeded, ) = checkUpkeep(""); // Error here

2 Answers 2


There are some of issues. The function checkUpkeep accepts bytes calldata but it is public. Solc generates an error with that combination.

function checkUpkeep(bytes calldata /* checkData */) public override returns ... {

The problem using calldata is that type of data cannot be created by the contract. It just could forward the existing data of that type.

One possible solution is to change the type to memory, then (bool upkeepNeeded, ) = checkUpkeep("") will work.

function checkUpkeep(bytes memory /* checkData */) public override returns ... {

Other function is to declare the function as external and modify the call to (bool upkeepNeeded, ) = this.checkUpkeep(""), because external function are called that way.


You're calling a solidity function that takes a bytes parameter, but you're passing in a string as the input (even though its an empty string).

You need to convert the input parameter to bytes before calling the function. Check out the unit test for Keepers in the Chainlink Hardhat Starter Kit for an example of how to do this:

const checkData = ethers.utils.keccak256(ethers.utils.toUtf8Bytes(""))
const { upkeepNeeded } = await counter.callStatic.checkUpkeep(checkData)

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.