Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
ERC-1822 proposes the Universal Upgradeable Proxy Standard (UUPS), a pattern in which a proxy stores state and delegates execution to an implementation that contains the upgrade logic.
This article explains the following proposal, with additional context and examples.
You can find my other proposal articles here.
Overview
The standard defines a proxy designed to work with compatible implementation contracts. The proxy stores the implementation address in a designated storage slot, reducing the risk of collisions with ordinary implementation state variables.
The upgrade mechanism checks whether a candidate implementation reports the expected compatibility identifier. Upgrades may be repeated or restricted by custom authorization logic. This check is not a guarantee that a candidate implementation has a compatible storage layout or correct business logic.
The proxy constructor also accepts encoded initialization data. This allows developers to choose among different initialization routines without modifying the proxy's runtime code.
Upgradeable contracts are typically divided into a proxy and an implementation contract.
The implementation contains executable logic. The proxy holds state and delegates calls to that implementation.
To upgrade the system, developers deploy a new implementation and update the implementation address stored by the proxy. The proxy's address and existing state can remain unchanged, provided the new implementation is compatible with that state.
Motivation
ERC-1822 aims to improve existing proxy designs and simplify the deployment and maintenance of proxies and their implementations. It also provides a consistent approach to proxy bytecode and initialization data, helping developers verify deployed contracts.
Terminology
delegatecall()
Suppose a user calls a function on contract A that is not explicitly implemented there. A's fallback function can forward the original calldata to contract B using delegatecall.
Contract B's code then executes in contract A's context. Storage reads and writes affect A, address(this) refers to A, and the original msg.sender and msg.value are preserved.
Proxy contract
The contract that holds persistent state and uses delegatecall to execute code from an implementation.
Logic contract
The implementation contract that defines the application's executable logic.
Proxiable contract
A base contract inherited by the implementation to provide compatibility checks and upgrade functionality.

Specification
The proposal defines a reusable proxy contract and a Proxiable base contract. The latter provides a mechanism for changing the implementation address without embedding application-specific upgrade logic directly in the proxy.
The authorization rules governing upgrades can be customized by the implementation.
Proxy contract
Functions
fallback
The proxy's fallback function delegates calls to the implementation. The original ERC-1822 example stores the implementation address at the slot derived from keccak256("PROXIABLE").
Using a designated high-entropy slot reduces the likelihood of collisions with ordinary sequential storage allocation. It does not eliminate the need to check storage layout compatibility between implementation versions.
The fallback function uses inline assembly.
For background on Solidity assembly, see:
function() external payable {
assembly { // solium-disable-line
// ロジックコントラクトのアドレスをロード
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
// コールデータをメモリの0x0番地にコピー
calldatacopy(0x0, 0x0, calldatasize)
// delegatecallを実行
let success := delegatecall(sub(gas, 10000), contractLogic, 0x0, calldatasize, 0, 0)
// リターンデータサイズを取得
let retSz := returndatasize
// リターンデータをメモリの0番地にコピー
returndatacopy(0, 0, retSz)
// 成功した場合はリターン、失敗した場合はリバート
switch success
case 0 {
revert(0, retSz)
}
default {
return(0, retSz)
}
}
}The original code comments describe the following operations.
- sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7) loads the implementation address from its designated storage slot.
- calldatacopy(0x0, 0x0, calldatasize) copies the incoming calldata to the beginning of memory.
- delegatecall(sub(gas, 10000), contractLogic, 0x0, calldatasize, 0, 0) delegates execution while preserving the proxy's execution context. The historical example requests a gas margin of 10,000 gas.
- returndatasize and returndatacopy obtain and copy the return data from the delegated execution.
- switch success returns the result if the call succeeds or reverts with the returned error data if it fails.
constructor
The proxy constructor accepts an implementation address and arbitrary encoded initialization calldata. This makes it possible to select among initialization functions with different argument types.
Solidity does not support multiple constructors in one contract, and a deployed contract's constructor cannot be invoked through delegatecall. The proposal's references to multiple constructors describe ordinary initialization functions serving constructor-like purposes.
Initialization routines must be protected against unintended repeated execution.
The same proxy bytecode can be used with different initialization calldata. Verification tools can decode the proxy constructor arguments and then interpret the embedded initialization data using the implementation ABI.
contract Proxy {
// ストレージ内のコード位置は keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"
// コンストラクタは任意の型の引数を受け入れる
constructor(bytes memory constructData, address contractLogic) public {
// ロジックコントラクトのアドレスを保存
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, contractLogic)
}
// ロジックコントラクトのコンストラクタを呼び出す
(bool success, bytes memory _ ) = contractLogic.delegatecall(constructData); // solium-disable-line
require(success, "Construction failed");
}
// フォールバック関数
function() external payable {
assembly { // solium-disable-line
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
calldatacopy(0x0, 0x0, calldatasize)
let success := delegatecall(sub(gas, 10000), contractLogic, 0x0, calldatasize, 0, 0)
let retSz := returndatasize
returndatacopy(0, 0, retSz)
switch success
case 0 {
revert(0, retSz)
}
default {
return(0, retSz)
}
}
}
}The main operations are:
- constructor(bytes memory constructData, address contractLogic) accepts the encoded initialization call and the implementation address.
- The assembly sstore operation records that address in the designated slot.
- contractLogic.delegatecall(constructData) executes the selected initialization function in the proxy's context.
- require(success, "Construction failed") reverts proxy deployment if initialization fails.
- The fallback function delegates subsequent calls to the currently configured implementation.
Proxiable contract
Proxiable is inherited by the logic contract to provide the upgrade mechanism. Its compatibility check helps prevent upgrades to implementations that do not report the expected identifier.
:warning: Warning: updateCodeAddress and proxiable must be present in the Logic Contract. Failure to include these may prevent upgrades, and could allow the Proxy Contract to become entirely unusable. See below Restricting dangerous functions
The historical proposal uses the term proxiable in its warning; the actual compatibility function shown in the code is proxiableUUID.
proxiable
The compatibility mechanism checks whether the new implementation reports the expected UUPS identifier. In the original example, that identifier is keccak256("PROXIABLE").
A design could introduce a version-specific identifier, such as keccak256("PROXIABLE-ERC1822-v1"), but the compatibility rules must agree across implementations. Changing the expected identifier without a migration strategy can prevent further upgrades.
The identifier alone does not establish that an upgrade is safe.
updateCodeAddress
Writes a new implementation address to the designated storage slot in the proxy's state when executed through delegatecall.
For example, the slot derived from keccak256("PROXIABLE") is:
0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7
Subsequent proxy calls use the new implementation. The proxiableUUID function provides the compatibility identifier used before writing the new address.
Key operations
contract Proxiable {
// ストレージ位置の定義 (keccak256("PROXIABLE") = 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
function updateCodeAddress(address newAddress) internal {
// 新しいアドレスのロジックコントラクトが互換性を持つか確認
require(
bytes32(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7) == Proxiable(newAddress).proxiableUUID(),
"Not compatible"
);
// 新しいアドレスをストレージに保存
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, newAddress)
}
}
// UUIDを返す関数
function proxiableUUID() public pure returns (bytes32) {
return 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7;
}
}- updateCodeAddress checks the candidate implementation's proxiableUUID and then stores its address using assembly if the identifier matches.
- proxiableUUID returns the fixed identifier expected by the upgrade mechanism.
The original ERC-1822 example uses the PROXIABLE slot. Modern UUPS implementations commonly use the ERC-1967 implementation slot with an ERC-1822-style proxiableUUID check. These conventions must not be mixed without checking the actual implementation.
Considerations when using proxies
Separating state and logic
A new implementation must preserve compatibility with the proxy's existing storage layout. In a conventional sequential storage model, developers should preserve the ordering and types of existing variables and append new variables after the existing layout.
The historical proposal recommends a shared base contract containing state variables so that new implementations can inherit the existing layout. Changes in inheritance order or base-contract storage can still create incompatibilities and must be checked.
The original article illustrates inheritance as follows.
Implementation A → Implementation B (inherits A) → Implementation C (inherits B)
Restricting dangerous functions
The compatibility check does not prevent an implementation from containing malicious or destructive logic. Upgrade functions must be protected by an appropriate authorization mechanism, such as an owner-only role.
The proposal historically recommended disabling control of the standalone implementation by initializing its owner to an inaccessible address such as address(1). Modern implementations commonly disable initializers on the implementation itself and separately initialize the proxy.
Operations involving SELFDESTRUCT, CALLCODE, or arbitrary delegatecall require particular care. The consequences of SELFDESTRUCT depend on the network's protocol rules. Compatibility identifiers do not protect against arbitrary storage writes, broken initialization, or malicious upgrades.
Implementation examples
Owned
The following example restricts calls to the upgrade mechanism to the owner.
contract Owned is Proxiable {
// ensures no one can manipulate this contract once it is deployed
address public owner = address(1);
function constructor1() public{
// ensures this can be called only once per *proxy* contract deployed
require(owner == address(0));
owner = msg.sender;
}
function updateCode(address newCode) onlyOwner public {
updateCodeAddress(newCode);
}
modifier onlyOwner() {
require(msg.sender == owner, "Only owner is allowed to perform this action");
_;
}
}The implementation's own owner state is initialized to address(1), while the proxy's corresponding storage initially contains zero. The constructor1 initialization function uses that distinction to initialize the proxy owner once.
ERC-20
Proxy contract
pragma solidity ^0.5.1;
contract Proxy {
// Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"
constructor(bytes memory constructData, address contractLogic) public {
// save the code address
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, contractLogic)
}
(bool success, bytes memory _ ) = contractLogic.delegatecall(constructData); // solium-disable-line
require(success, "Construction failed");
}
function() external payable {
assembly { // solium-disable-line
let contractLogic := sload(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7)
calldatacopy(0x0, 0x0, calldatasize)
let success := delegatecall(sub(gas, 10000), contractLogic, 0x0, calldatasize, 0, 0)
let retSz := returndatasize
returndatacopy(0, 0, retSz)
switch success
case 0 {
revert(0, retSz)
}
default {
return(0, retSz)
}
}
}
}Logic contract
contract Proxiable {
// Code position in storage is keccak256("PROXIABLE") = "0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"
function updateCodeAddress(address newAddress) internal {
require(
bytes32(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7) == Proxiable(newAddress).proxiableUUID(),
"Not compatible"
);
assembly { // solium-disable-line
sstore(0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7, newAddress)
}
}
function proxiableUUID() public pure returns (bytes32) {
return 0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7;
}
}
contract Owned {
address owner;
function setOwner(address _owner) internal {
owner = _owner;
}
modifier onlyOwner() {
require(msg.sender == owner, "Only owner is allowed to perform this action");
_;
}
}
contract LibraryLockDataLayout {
bool public initialized = false;
}
contract LibraryLock is LibraryLockDataLayout {
// Ensures no one can manipulate the Logic Contract once it is deployed.
// PARITY WALLET HACK PREVENTION
modifier delegatedOnly() {
require(initialized == true, "The library is locked. No direct 'call' is allowed");
_;
}
function initialize() internal {
initialized = true;
}
}
contract ERC20DataLayout is LibraryLockDataLayout {
uint256 public totalSupply;
mapping(address=>uint256) public tokens;
}
contract ERC20 {
// ...
function transfer(address to, uint256 amount) public {
require(tokens[msg.sender] >= amount, "Not enough funds for transfer");
tokens[to] += amount;
tokens[msg.sender] -= amount;
}
}
contract MyToken is ERC20DataLayout, ERC20, Owned, Proxiable, LibraryLock {
function constructor1(uint256 _initialSupply) public {
totalSupply = _initialSupply;
tokens[msg.sender] = _initialSupply;
initialize();
setOwner(msg.sender);
}
function updateCode(address newCode) public onlyOwner delegatedOnly {
updateCodeAddress(newCode);
}
function transfer(address to, uint256 amount) public delegatedOnly {
ERC20.transfer(to, amount);
}
}These historical examples illustrate the proxy, storage layout, implementation lock, and upgrade authorization. They are not a complete production-ready ERC-20 implementation. In particular, the final example's initialization routine needs explicit protection against reinitialization, and its token logic requires the complete storage and interface definitions. The original source code and comments are reproduced unchanged.
Citation
Gabriel Barros gabriel@terminal.co, Patrick Gallagher blockchainbuddha@gmail.com, "ERC-1822: Universal Upgradeable Proxy Standard (UUPS) [DRAFT]," Ethereum Improvement Proposals, no. 1822, March 2019. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-1822.
Conclusion
ERC-1822 describes a proxy architecture that keeps state in the proxy and upgrade logic in the implementation. It enables implementations to be replaced while preserving the proxy address and compatible state. Secure authorization, initialization, and storage layout validation remain essential.
If you have questions, feel free to contact me on Twitter.
You can also find my work on the following sites.




