ERC.20 approve via other contract?

Before doing a transferFrom a user has to approve the amount and spender with that function on the ERC20 contract.
However user has also to provide the spender.
As a convenience, as the user (msg.sender) has already (in my case) a reference to the contract which should be allowed to spend the token, I wanted to add a function within that contract.
Calling that contract would add its address as the spender and forward it to the correct ERC20 contract. User/msg.sender would not need to know (wnen calling the function) the contract’s or ERC20 address.
However , it does not work, looks like the msg.sender is not kept when forwarding the call to the ERC20 contract …

    function approveStakingToken(uint256 _amount) external returns (bool) {
        IERC20(address(stakingToken)).approve(address(this), _amount)

This does not work either …

    function approveStakingToken(uint256 _amount) external returns (bool) {
        (bool success, ) =
                abi.encodeWithSignature("approve(address,uint256)", address(this), _amount)
        return success;

Yeah those things will not work. The user has to send the approve transaction themselves.

1 Like