The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Watch Our Students Break Down the Diamond Standard in Blockchain || Cohort X

The picture loads from YouTube. The player loads only when you press Play. Turn on captions in the player if you need them.

A Cohort X student explains the Diamond Standard, EIP-2535, as a contract of contracts that makes smart contracts modular and upgradable. They describe a main diamond contract that uses a fallback function and delegate calls to separate facets, with the state kept in shared storage.

Not by We Them Media Channel: Web3Bridge. Published Thursday 2 May 2024.

Titles are the owner’s. It plays from their channel.

Transcript

This transcript may contain errors. This video belongs to Web3Bridge. Letters mark each change of speaker.

These are the speakers’ own words. We have not checked their claims.

0:07 A: A lot of people have been hearing about Diamond Standard here and there, look at it like a very complex stuff, but I'm going to simplify it down to the barest minimum that I can.

0:16 B: I will tell you, Diamond Contract is a contract of contracts. Now what do I mean by that?

0:21 C: So Diamond Standard are simply upgradable contracts.

0:27 D: It is a design pattern actually to modularize our smart contract.

0:33 E: This was built by the EIP-2535, which is the multi-facet or proxy facet. So the idea behind it, just like a diamond, right? You can- when you have a diamond, you can cut out different facets out of the diamond to create a new diamond, right? So this facet are just parts where you cut out of the diamond. So talking about, let's now relate it to smart contracts. Facets are different, um, files. They have different Solidity files which implement functions and also import, right? They use the state variables which is stored in a library.

1:16 D: The major part of the Diamond Standard, we have the diamond and the facet. The faucet acts as the modularized part, and the diamond is the main smart contract. Faucet is just like all our functions, our logic functions and all, but it doesn't have any state variables. So the state variables are being stored in the app storage. So basically, Diamond Standard is where the faucets interact with the diamond that is being deployed and The Diamond performs a delegate call to the Faucet.

1:49 B: So the 2 things that we need to keep, um, that we need to take notice when it comes to Diamond Standard is the fallback function and the delegate call.

1:57 A: It works with simple analogies like, um, delegate calls, fallback function, and then you have to understand concept of function selectors and the rest of them.

2:09 B: The Diamond Standard depends more on the fallback function because why? With that already, he uses that to delegate calls to other faucets that he needs.

2:17 F: It uses the delegate call, which is a low-level call to delegate logic to update states in that contract.

2:26 C: Since the blockchain is immutable, sometimes when we deploy contracts and want to make changes to it, it's a little bit- it's impossible virtually. But with Diamond Standard, Diamond Standard opens room for upgradability. Because when you deploy, you can deploy other faucets, and these faucets will be able to be accessed by already deployed contracts.

2:47 D: So the major purpose of this, um, the EIP-2535 standard is just for efficiency, modularity, and upgradability.

2:57 C: So the EIP-2535 was made to enable us to upload multiple, um, to increase the size of smart contracts. And since things deployed to the blockchain are mostly immutable, that means they cannot be changed, the Diamond Standard makes it possible for us to upgrade- it makes it possible for us to upgrade already existing contracts.

3:19 A: So technically what happens is, you all know that smart contracts cannot be changed once they are deployed on the blockchain. So a Diamond comprises of 2 smart contracts, which is one, a proxy contract, and the second is the implementation contract. So the proxy contracts hold the states of the diamond.

3:37 B: So it just helps you manage a lot of functions without having these functions. The funny thing is that diamond contracts just have one function, and that's a fallback function, but it can tap into as many functions as it wants. Yes.

More from this hub

Something wrong, or a video you want off this page? Write to wethem.xyz@gmail.com and it is fixed or taken down within 48 hours.