2

I tested my code on the Arbitrum Goerli network, and it worked because the test USDC contract is the default one with approve and transfer functions.

Now I want to go live, and I see that USDC (0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8) ABI is different since it uses a proxy contract (0x1eFB3f88Bc88f03FD1804A5C53b7141bbEf5dED8).

How do I approve and transfer USDC? I tried approving the proxy contract but the transfer fails for some reason:

USDC = IERC20(0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8); USDC.transferFrom( msg.sender, address(this), _amount.mul(1e6) ); .

I'm calling the transfer on the main contracts. What's the proper way to approve spending and do the transfer when there is a proxy contract?

1 Answer 1

2

With proxy contracts, you have the proxy contract and the implementation contract. First off you have your terminology a little mixed up.

In this case, the proxy contract would be 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8

And the implementation contract would be 0x1eFB3f88Bc88f03FD1804A5C53b7141bbEf5dED8

You are referring to the implementation contract as the proxy. The proxy is the contract that just grabs the logic to use of the implementation, is very small, and uses delegateCall.

When you go to use the contract, everything including the address you approve goes to the proxy contract. Proxies are managed with delegateCall, so they hold all the state and essentially operate like that contract if you make any calls to it.

For your case here, your must call approve on the proxy contract (0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8), and then also call the transfer on the proxy contract.

Never interact with the implementation contract when you have a proxy system. Even if it doesn't revert, its not doing anything useful. All the state you care about is in the proxy contract, and you should only interact with it.

2
  • Thank you so much for the quick and detailed explanation. Commented Mar 13, 2023 at 22:21
  • Happy to help !
    – Bruce
    Commented Mar 16, 2023 at 22:14

Your Answer

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

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