Blockchain & Cryptocurrency Glossary

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

  • search-icon Clear Definitions
  • search-icon Practical
  • search-icon Technical
  • search-icon Related Terms

Proxy Contract

1 min read
Pronunciation
[prok-see kon-trakt]
Analogy
Imagine a P.O. Box (the proxy contract address) that you always use for mail. The actual contents of your office (the logic contract with its functions) might move to a new building or get renovated, but your P.O. Box address remains the same. The P.O. Box simply forwards mail to your current office location. If you renovate or move offices, you just tell the P.O. Box the new forwarding address.
Definition
In smart contract development, a proxy contract is a contract that acts as an intermediary, forwarding calls and messages to another contract (the logic contract) while maintaining its own storage and address. It's a core component of most smart contract upgradeability patterns.
Key Points Intro
Proxy contracts enable smart contract upgradability by separating state from logic.
Key Points

A contract that users interact with, holding the contract's state (data and balances).

Delegates function calls (using `delegatecall` in EVM) to a separate 'logic contract' or 'implementation contract'.

To upgrade, the proxy is reconfigured to point to a new logic contract version.

The contract address remains the same, and the state is preserved across upgrades.

Common patterns include Transparent Proxy Pattern and UUPS (Universal Upgradeable Proxy Standard).

Example
OpenZeppelin's upgradeable contract libraries provide implementations of proxy contracts that developers can use to make their smart contracts upgradeable. A user interacts with the proxy address, unaware that the logic might be served by different implementation contracts over time.
Technical Deep Dive
The `delegatecall` opcode is key to proxy contracts. When a proxy contract makes a `delegatecall` to a logic contract, the logic contract's code is executed in the context of the proxy contract. This means the logic contract can modify the proxy contract's storage, and `msg.sender` and `msg.value` remain those of the original caller to the proxy. The proxy itself contains minimal logic, primarily the `delegatecall` forwarding mechanism and an upgrade function to change the address of the logic contract.
Security Warning
Proxy contracts introduce complexity. Potential issues include storage collisions (if the proxy and logic contract try to use the same storage slots), selector clashes (if functions in the proxy and logic have the same signature), and vulnerabilities in the upgrade mechanism itself. Careful design and auditing are essential.

Proxy Contract - Related Articles

No related articles for this term.