Why the same ERC1967Upgrade.sol contract is needed both in proxy and implementation contracts?

I’m curious why both ERC1967Proxy (UUPS proxy) and UUPSUpgradeable.sol (implementation side lib) contracts have the same dependency - ERC1967Upgrade.sol

My best guess is that the ERC1967Upgrade.sol logic is needed only at proxy creation time and the reason to use the same lib is to make sure that storage slots are not not mixed up. Is it so? Is there another motivation?

ERC1967Upgrade provides functions to deal with EIP1967 storage slots, so it is used both in the proxy (e.g. during creation as you mentioned) and also in the UUPS implementation (e.g. during upgrade which is called through the proxy with delegatecall).

1 Like