Proxy contracts are an essential tool in Ethereum and other EVM-compatible networks, enabling developers to separate a contract's logic from its data storage. In essence, a proxy contract acts as a middleman: it delegates function calls to another contract—often referred to as the implementation or logic contract—where the actual code execution takes place. This separation is vital for achieving upgradability while preserving the contract’s state (data).
The fundamental idea behind proxy contracts is to allow for the upgrade or replacement of the implementation contract without changing the state or address of the proxy contract. This allows developers to fix bugs, add new features, or upgrade the logic without requiring users to interact with a new contract.
In this article, we’ll explore the importance of proxy contracts, their common use cases, and the different standards. We’ll also discuss how to recognize them on the blockchain.
A proxy contract is a smart contract on the Ethereum network that delegates all or most of its function calls to another contract, known as the implementation contract or logic contract. The proxy itself contains minimal logic, primarily serving as a gateway to forward requests (typically using a call that allows it to execute code from another contract in its own context) to the implementation contract, which holds the actual business logic and data processing rules.
The key idea is to separate the contract’s state (data storage) from its logic (code). The logic can then be upgraded or modified without affecting the stored data.
Once a smart contract is deployed on Ethereum, its code is immutable and cannot be changed. This is beneficial for ensuring trust and transparency. However, it becomes a problem when developers need to fix bugs, add features, or upgrade the system.
Proxy contracts solve this by allowing the contract logic to be upgraded without affecting the data. The proxy contract always points to the current implementation contract. You can upgrade the implementation contract without losing state or requiring users to migrate to a new contract.
Deploying large, complex contracts can be expensive due to high gas costs, especially when deploying the same contract multiple times (e.g., in a factory pattern).
By using proxies, such as ERC-1167 minimal proxy contracts (see below), you can deploy lightweight proxy contracts that delegate logic execution to a single, centralized implementation contract. This reduces gas costs because the proxy contract is much smaller and simpler.
Discovering a vulnerability or bug in a smart contract after deployment can result in significant losses or security issues, as the immutable nature of the blockchain makes patching difficult.
Proxy contracts enable developers to push security updates or bug fixes by pointing the proxy to a new implementation contract. This allows contract creators to maintain their contracts post-deployment without affecting users’ data or requiring them to interact with new addresses.
Unfortunately, there have been increasing cases of fraud involving proxy contracts. In these cases, attackers replace the implementation contract with one containing vulnerabilities. Thus, in some areas, the use of proxy contracts is considered a red flag.
Proxy contracts support modular design by separating the logic into different facets, such as in the ERC-2535 Diamond Standard (see below). This allows you to replace, add, or remove modules (or facets) as needed, providing greater flexibility in building and maintaining complex decentralized applications (DApps).
There are several different proxy standards on Ethereum, each serving specific purposes:
Provides a way to create minimal proxy contracts, which are highly gas-efficient and delegate all logic to a master implementation contract. This is commonly used in factory patterns where you need many instances of the same logic.
In this model, the logic for upgrading is in the implementation contract itself. This provides flexibility but requires careful management of upgradeability.
Defines standard storage slots for proxy implementation and admin addresses, making proxy contract management easier and more transparent.
A more advanced proxy mechanism that allows multiple “facets” (modular contracts) to be added, removed, or replaced. This is useful for complex systems where different parts of the contract need to evolve independently.
Since each contract has a different implementation and its own unique interface, we need to evaluate each implementation individually to identify proxy contracts. Let’s explore the features in the contracts that will help us determine whether a contract belongs to a proxy contract.
0x363d3d373d3d3d363d73<implementation_address>5af43d82803e903d91602b57fd5bf3
0х3d3d3d3d363d3d37363d73<implementation_address>5af43d3d93803e602a57fd5bf3
Chainlens simplifies identifying and analyzing proxy contracts on EVM-compatible networks. By supporting different proxy standards, Chainlens identifies and labels contracts that implement proxy patterns.
This allows developers and users to explore smart contracts and their underlying structures, even when the contracts aren’t verified. By parsing bytecode and identifying common patterns, the explorer helps uncover critical information, such as the proxy’s implementation address, storage slots, and upgrade functions.
Each of these proxy standards — ERC-1167, ERC-1822, ERC-1967, and ERC-2535 — has a unique approach to managing implementation addresses, handling upgrades, and delegating logic. By examining the storage slots, function signatures, and bytecode, you can identify the type of proxy contract in use. This helps developers and users understand the behavior and upgradeability of the smart contracts they interact with, which is essential for maintaining secure and efficient decentralized applications.
With Chainlens’ support for proxy contracts, it’s straightforward for users to track their usage on networks. Additionally, with Chainlens’ ability to manage verified smart contracts, you can invoke update functions directly via its UI, simplifying contract management.
You can see some examples of proxy contracts in Chainlens for Holesky here.
If you'd like to run Chainlens on your network, please contact us to learn more.