Upgradeable Smart Contracts Made Easy
Upgradeable smart contracts are a desirable design practice given today’s extremely important and ever-changing landscape for smart contract security. In this article, we deploy a plain ERC20 contract, and later upgrade it to a mintable token contract to allow for the functionality of minting new tokens.
However, it is important to keep in mind that there are some key design principles to be followed while coding such contracts. On the surface, smart contract upgradeability may seem like a pretty cool feature to have. However, it violates a fundamental property of Blockchains — immutability. I will be creating a follow-up article which addresses this topic. But for now, let’s focus on the implementation alone.
We use ZeppelinOS to achieve our task.
Refer to the diagram below for a simple reference on how ZeppelinOS achieves upgradeability. I’m not going to delve deeper into the technical aspects as they already have pretty good documentation in place.
Let’s get into writing code. For this deployment, I’m going to use Ganache as my local Ethereum node. I’m also going to assume you already have node.js installed on your system.