Type bytes memory is not implicitly convertible to expected type bytes calldata

Hey, I've written a function using openzeppelin TimeLockController.sol's schedule function. I want to call a function from another deployed contract using my timelock contract at some time, means after some delay.

I wrote it like this...

import "@openzeppelin/contracts/governance/TimeLockController.sol";

interface Ierc20 {
    function mint(address to, uint amount) external; 
    function burn(uint amount) external;
}

contract TimeLock is TimelockController {

    function scheduleMintFuctionCall(address to, uint amount) public {

         //the target address is my erc20 contract's address whos function I want to call
        address target = 0x5FbDB2315678afecb367f032d93F642f64180aa3; 
        bytes calldata data = abi.encodePacked(Ierc20(target).mint(to, amount));
        uint256 value = 10000000;
        bytes32 salt = keccak256("MY_SALT");
        uint256 delay = block.timestamp + 3 minutes;
        schedule(target, value, data, bytes32(0), salt, delay);
    }

}

Now, I'm getting the error in data part which is the function call from another contract with the parameters and I'm encoding it. But I'm getting the error in the same line

Type bytes memory is not implicitly convertible to expected type bytes 
calldata.

anyone please help.

Hi, welcome! :wave:

I think you use a wrong way, you can have a look at the solidity documentation: Units and Globally Available Variables — Solidity 0.8.12 documentation (soliditylang.org)

1 Like

Now, I used the abi.encodeSignature like below

bytes calldata data = abi.encodeWithSignature("Ierc20(target).mint(address, uint256)", to, amount);

But again I'm getting the error Type bytes memory is not implicitly convertible to expected type bytes calldata.

please help me, I'm stuck in this for two days.

I think it should be abi.encodeWithSignature("mint(address, uint256)", to, amount); There is an example, you can have a look:

But I'm getting the mint function from my Ierc(target). Without it, would the function work?