Upgradeable Diamond - ERC20

Upgradeable Diamond - ERC20

Diamond Standard contract by Nick Mudge leverages on using EIP 2535. It aims towards achieving modular smart contract systems that can be upgraded/extended after deployment.

One of the limitations of smart contracts is the maximum contract size. A smart contract can be a maximum of 24KB or it will run out of gas. Diamond on the other hand has no size limit. It means when next you have code that has a very large base, you can try out diamond standard. A diamond contract has external functions that are supplied by contracts called facets.

Diamond Terminologies

The following are some of the terminologies used in a diamond contract.

  1. A diamond is a facade smart contract that delegates call into its facets to execute function calls. A diamond is stateful. Data is stored in the contract storage of a diamond.

  2. A facet is a stateless smart contract or Solidity library with external functions. A facet is deployed and one or more of its functions are added to one or more diamonds. A facet does not store data within its own contract storage but it can define state and read and write to the storage of one or more diamonds. The term facet comes from the diamond industry. It is a side or flat surface of a diamond.

  3. A loupe facet is a facet that provides introspection functions. In the diamond industry, a loupe is a magnifying glass that is used to look at diamonds.

  4. An immutable function is an external function that cannot be replaced or removed (because it is defined directly in the diamond, or because the diamond’s logic does not allow it to be modified).

  5. A mapping for this EIP is an association between two things and does not refer to a specific implementation.

An implementation of the diamond standard is done below, using Foundry. Feel free to check it out on this GitHub link. You are free to explore and have a feel of Diamond!!!

ERC20_Diamondtandard