1

What I would like to do is something like this:

function testCall(uint amount) public virtual returns (bool) {
address tta = address(0xE7B6....);    
    
(bool success, bytes memory result) = tta.delegatecall(abi.encodeWithSignature("approve(address, uint256)", address(this), amount));
return success;
}

The token looks like this (has the approve function)

However, whenever the function is executed, it reverts with an error.

What am I doing wrong?

What I need to accomplish is to let the user approve the contract to make a transferFrom by executing the contract's testCall() function first.

2
  • Get rid of the space character in "approve(address, uint256)". Aug 22 '20 at 18:42
  • As you can learn from the official documentation: "Parameter types are split by a single comma - no spaces are used". Aug 22 '20 at 18:50
1

You are adding a space in your function which is producing a different method signature.

> provider.eth.abi.encodeFunctionSignature('approve(address, uint256)')
0x8b069f2a

provider.eth.abi.encodeFunctionSignature('approve(address,uint256)')
0x095ea7b3

If you remove the space, it should work!

2
  • Alright, will try, thanks! Aug 23 '20 at 23:58
  • Edit: yes, it works! (sorry it took so long to approve the answer) Aug 29 '20 at 11:30

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.