Proxy Contracts
In the Proxy Pattern, two smart contracts are involved: the Proxy Contract and the Implementation Contract.
The Proxy Contract acts as an intermediary (also referred to as the Storage Layer in this context), delegating all function calls to the Implementation Contract, which contains the actual logic of your contract.
The Implementation Contract, also referred to as the Logic Layer, is the contract that you can upgrade or patch over time without disrupting the proxy contract or losing data.
The Proxy Contract maintains a reference to the Implementation Contract by storing its address as a state variable. Users do not interact directly with the Implementation Contract; instead, all user calls are sent to the Proxy Contract, which then forwards (or delegates) the calls to the Implementation Contract using the delegatecall
function. This ensures that any logic execution happens within the context of the Proxy Contract, meaning that it is the Proxy Contract that holds the state variables and manages the storage.
This design allows the contract's logic to be upgraded by simply deploying a new Implementation Contract and updating the reference address in the Proxy Contract, all while keeping the contract's state intact.
This approach ensures that your smart contracts remain flexible and up-to-date while preserving critical state data across upgrades.
Last updated