Transparent vs UUPS Proxies
0 CONTENTS
*post-contents*
- 1................................................................................
- 2................................................................................
- 3................................................................................
- 4................................................................................
- 5................................................................................
1 INTRO
Proxies are a type of smart contract that allows you to upgrade your contract logic without having to redeploy the entire contract. This is useful because it allows you to fix bugs or add new features to your contract without disrupting your users.
There are two main types of proxies: Transparent and UUPS (Universal Upgradeable Proxy Standard).
2 TRANSPARENT PROXIES
Transparent proxies are the simpler of the two types of proxies. They work by storing the address of the implementation contract in their own storage. When a user calls the proxy contract, the proxy contract simply forwards the call to the implementation contract.
To upgrade a transparent proxy, the admin of the proxy contract simply calls the
upgrade()
function and passes in the address of the new
implementation contract. The proxy contract will then update its storage to
point to the new implementation contract.
3 UUPS PROXIES
UUPS proxies are more complex than transparent proxies, but they offer more flexibility. UUPS proxies use a special type of contract called a logic contract. The logic contract contains all of the code for your contract. The proxy contract simply forwards all calls to the logic contract.
To upgrade a UUPS proxy, you must first deploy a new logic contract. Then, you
must call the upgrade()
function on the proxy contract and pass in
the address of the new logic contract. The proxy contract will then update its
storage to point to the new logic contract.
4 WHICH PROXY?
In general, I recommend that you use a UUPS proxy unless you have a specific reason to use a transparent proxy. UUPS proxies are more flexible and offer better security.
Here is a table that summarizes the key differences between transparent and UUPS proxies:
Feature | Transparent proxy | UUPS proxy |
---|---|---|
Upgrade process | The admin of the proxy contract calls the | The proxy contract forwards all calls to the logic contract. The logic contract can then implement its own upgrade logic. |
Gas overhead | Higher | Lower |
Flexibility | Less | More |
5 CONCLUSION
Proxies are a powerful tool that can help you to make your smart contracts upgradeable. When choosing a proxy, you should consider your specific needs and requirements. If you are unsure which type of proxy to use, I recommend that you use a UUPS proxy.
TAGS
*post-tags*
- [1]