ERC-1538 · Withdrawn · ERC · 2018-10-31
ERC-1538: Transparent Contract Standard
An early upgradeable-proxy pattern that routes each function to its own delegate contract and logs every change with events; withdrawn in favour of the Diamond standard.
What problem does it solve?
Immutable contracts cannot be fixed or improved, while typical upgradeable contracts can be changed silently by their owners. Contracts are also limited to 24 KB of code, which large systems quickly hit.
ERC-1538, the "Transparent Contract Standard", tried to find a middle ground: a single, permanent contract address whose functions can be added, replaced or removed, with every change documented on-chain in a standard format so anyone can audit the contract's history. Because functions can live in many separate contracts, total code size is practically unlimited.
How it works
- The transparent contract keeps a mapping from function selector to delegate contract. Its fallback function looks up
msg.sigand runs the matching code withdelegatecall, so delegates operate on the transparent contract's storage. Unknown selectors revert. - Functions written directly in the transparent contract are unchangeable functions; they can never be replaced.
- All changes go through
updateContract(address delegate, string functionSignatures, string commitMessage). The signatures are concatenated, e.g."approve(address,uint256)balanceOf(address)". Passingaddress(0)asdelegateremoves those functions. - Each changed function emits
FunctionUpdate(functionId, oldDelegate, newDelegate, functionSignature), and each call emits oneCommitMessage(message)explaining why, much like a version-control log. - An optional
ERC1538Queryinterface lists all functions and their delegates. - Ownership and authorisation for upgrades are left to the implementer. Source code of the contract and all delegates must be publicly verified.
Sample code
The core routing idea in current Solidity:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract RoutingProxy {
mapping(bytes4 => address) internal delegates;
event FunctionUpdate(bytes4 indexed functionId, address indexed oldDelegate,
address indexed newDelegate, string functionSignature);
event CommitMessage(string message);
fallback() external payable {
address delegate = delegates[msg.sig];
require(delegate != address(0), "Function does not exist.");
assembly {
calldatacopy(0, 0, calldatasize())
let ok := delegatecall(gas(), delegate, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch ok
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
}
Adding functions from a script:
await transparent.updateContract(
erc721Delegate,
"balanceOf(address)ownerOf(uint256)transferFrom(address,address,uint256)",
"Adding ERC-721 functions",
);
Things to know
- Status: Withdrawn. The author replaced it with ERC-2535 Diamonds, which keeps the per-function routing and change events but uses selector arrays and a standard
diamondCutfunction. - For simpler single-implementation proxies, see the storage slots standardised in ERC-1967.
- Whoever controls
updateContractcan add a function that does anything with the contract's storage and funds; transparency makes this visible, not impossible. - Delegates share one storage space, so storage layout must be managed carefully to avoid collisions.