I have simple contract and it has a function to call ERC20 token contract:

function _approve(uint256 amount, address to) external payable returns (bool){
        (bool ok,) =
         linkTokenAddress.call(abi.encodeWithSignature("approve(address, uint256)",to ,amount));
         return ok;

But when i call this function, it reverts. what is the problem?

this is a tx details you can check

1 Answer 1


But when i call this function, it reverts. what is the problem?

The issue is the signature argument of the abi.encodeWithSignature function call is incorrect. The proper signature is approve(address,uint256) (notice there is no space after the comma).

You can check the solidity docs here where they document how to properly generate the signature. The solidity by example site also has a tutorial displaying this here.

  • Would you edit my function that i i can see how?
    – Alireza
    Mar 19 at 6:45
  • Hi,just remove space and test it,like below: linkTokenAddress.call(abi.encodeWithSignature("approve(address,uint256)",to,amount)); Mar 19 at 9:24
  • I've tried that but it still doesn't work. here is transaction hash: goerli.etherscan.io/tx/…
    – Alireza
    Mar 19 at 9:44
  • The transactions you are providing don't call the function which you are asking about in the original post. You can check the parity traces and see the function calls don't match. I'd recommend you publish the source before asking any more. Mar 19 at 20:56

Your Answer

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

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