5

Suppose that you have an upgradeable proxy "Foo" that calls an implementation contract "Bar" via DELEGATECALL.

In "Bar", there is a function that uses the Solidity syntax address(this) to retrieve the address of the current contract.

What is the "current" contract when the call is made via the upgradeable proxy "Foo"?

5

Remember how DELEGATECALL works:

DELEGATECALL basically says that I'm a contract and I'm allowing (delegating) you to do whatever you want to my storage. DELEGATECALL is a security risk for the sending contract which needs to trust that the receiving contract will treat the storage well.

So the answer is that address(this) will return the address of the "Foo" proxy, not of the "Bar" implementation. This wouldn't be a "delegation" if the answer was otherwise, would it?

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.