Proxy Simplified Series.

Proxy Simplified Series.

Photo by fabio on Unsplash

Introduction to Proxy:

Recently I learned a ton about Proxy in Smart Contract development and I am so excited to share all my knowledge in this article. I believe they’re many people still in the dark and will love to get a simplified understanding of what Proxy’s are as regards to smart contracts.

I have noticed the use of ambiguous language in terms of explaining some of these topics in Smart contract development so I’ll try to explain what Proxy’s are, like I would to a 10 year old.

Take a deep breath let’s dive in.

What is a Proxy?

Pls Note:

  1. The Proxy takes commands or as developers will say implements the functions or functionality of a contract called an Implementation contract.
  1. Users interact directly with the Proxy contract not the implementation contract.

    ( this will help you understand what we are about defining below)

A proxy is an entirely different/separate contract that takes commands or instructions from another contract and implements all the commands/instructions of the contract.

Let’s say the proxy is contract A and the other contract which it takes orders from which is also known as the Implementation contract is contract B.

When a call is made to the Proxy contract A, it directs the call or delegates the call to the implementation contract B.

So it acts as an intermediary or abstract contract that delegate calls ( forwarding function calls to the implementation)

Now there’s a spin to it. The implementation contract doesn’t update its storage or sets storage as all that is done in the proxy contract (except for some few exceptions but lets us not divert let’s stay in line). It just feeds the Proxy instructions.

It seems like I’m moving too fast. Don’t be scared just pay attention.

I want you to understand that the proxy and the implementation contract are all connected.

Let’s digress a little bit.. to shed more light on what we are discussing.

In Smart contracts there’s something called storage (permanent memory). I believe you should know this. In blockchain contents stored in the storage are stored on the chain and can be modified as need be. I want you to understand that these things are neither just white or black as they are grey areas too.

Once some storage parameters have been initialized using a constructor which is done during the initial setup, which is the creation of the contract storage itself including the structure and configuration they can not be altered or changed and are immutable after contract deployment. The changes that are made thereafter to the storage are more like updates to the storage and not some sort of restructuring of the storage. I hope this is clear as day light.

Back to the subject of discussion; Proxy.

A normal contract will always have the storage and the logic code contained in it. Like I said above, the storage of the contract is updated as updates are made to the state but in the case of a Proxy, the state or storage of the implementation contract is contained inside the Proxy contract and also updated inside the Proxy contract.

That means the proxy contract implements the logic of the implementation contract and updates storage changes.

I know by now you might be asking what’s the use of all this stuff we have been talking about.

The USE of PROXY;

The main benefit of using a Proxy contract is because of UPGRADABILITY.

Normally after a smart contract is deployed it’s functionality are immutable. This simply means that any upgrades that’s to be made to the implementation contract would require deploying a new contract and transferring storage data from the old contract to the new contract. But with a proxy contract, Whenever an upgrade is required the new version of the implementation contract is deployed and the proxy is updated as well to point to the new version of the implementation contract. Thus paving way for a smooth transitioning without giving issues. Bug fixes, upgrades, addition of new features are so much easier to implement due to the flexibility that the proxy contract provides.

I really hope this article gives you the basic understanding that’s needed as regards this topic.

In my next article I’ll be explaining the downsides, issues etc to Proxy’s and the fixes that have been put in place to improve them.

Thanks for reading.

Follow me on Twitter