ERC-897 Proxy contract identification standard (DelegateProxy)
Stagnant · Other · created 2018-02-21
Lets a proxy contract tell callers, through standardized functions, whether it is a proxy, how it operates, and where the actual logic address is.
Why it is needed
Proxy patterns that delegate logic to another contract for contract upgrades or low-cost cloning are widely used, but because each implementation does things differently, there was no common way for outsiders to tell which contract is a proxy or where the real logic contract lives. As a result, tools like block explorers could only show the proxy's own code, not the ABI and code of the implementation contract that actually runs. Projects that implement proxies directly, such as aragonOS and zeppelinOS, each use different approaches, making it hard for general-purpose tools to recognize and handle them uniformly.
What to implement
function proxyType() public pure returns (uint256 proxyTypeId);: Returns a value indicating whether this contract is a proxy, and if so, what type of proxy.function implementation() public view returns (address codeAddr);: Returns the address of the actual logic contract that the proxy is delegating calls to at this moment.
In depth
What is being standardized is the interface, not the implementation
The original text states that standardizing DelegateProxy's specific implementation approach itself has little value, but agreeing on a common interface that all proxies can use has great value. In other words, this standard does not address how a proxy handles delegated calls (e.g. how delegatecall is implemented), but only unifies the channel through which outsiders identify and query a proxy.
The meaning of the address returned by implementation()
The code address returned by implementation() is the address the proxy delegates to for that moment and that message. In other words, it is defined not as a fixed, constant value but as one that can vary depending on when it is called, so an upgradeable proxy may return a different address at different times.
Determining whether something is a proxy via proxyType()
Calling proxyType() is the way to check whether a given contract is a proxy or not. If this function does not exist, the call fails, or it returns 0, the contract can be treated as not a proxy. It is declared as a pure function, so it cannot return different values depending on state changes and must always return the same value.
Forwarding proxy (id=1)
If id is 1, it means the proxy always delegates to the same code address. For this type, the invariant must hold that once a nonzero code address is returned, that address must never change afterward.
Upgradeable proxy (id=2)
If id is 2, it means the code address the proxy delegates to can change according to arbitrary logic. This logic can be implemented in the proxy contract itself, or in the logic on the side the proxy delegates to.
Benefit: improved source code verification on explorers
Block explorers like Etherscan currently only show the proxy contract's own code when you look up a proxy contract, and cannot show the code or ABI of the implementation contract that actually holds the logic. Standardizing this interface would let explorers call implementation() to find the actual implementation contract and show its ABI and code together.
Reference implementation
The original text cites aragonOS's AppProxyUpgradeable, AppProxyPinned, KernelProxy, and zeppelinOS's Proxy contract as examples that use this interface. However, the standard itself does not prescribe these implementation approaches, only the common interface.
Proposal status
This proposal is in Stagnant status, meaning discussion has stopped and is no longer progressing.