The One Question bounty closes Thursday 10 December.

Join in
We Them Media logo We Them Media Support us

Students Explain Diamond Standard (EIP-2535) | Week 11

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

James, a Cohort 9 student, recaps week eleven on upgradeable contracts and the Diamond Standard. They explain separating storage from code, why proxy contracts hit a size limit, and how facets, function selectors, delegate calls and diamond storage let a contract keep adding code.

Not by We Them Media Channel: Web3Bridge. Published Wednesday 15 November 2023.

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:09 A: Web3 Bridge Cohort 9, sponsored by Base.

0:11 B: Hi guys, it's James and I'm here to talk about my week 11 at Web3 Bridge. So, um, week 11 we delved into advanced Solidity and we were taught the Diamond Standard. And what the Darwin Standard is, is like it's an upgradeable contract. So the way smart contracts work is once you deploy them, they are immutable, which means you cannot change the code. But now what upgradeable contracts do for us is even though we can't change the code, even though we cannot change the code in our smart contract, we can decide to separate the storage from the code. And we'll now, instead of putting everything as one, we'll make sure we have a pointer in our main smart contract that points to the code. And this way we'll have a function in our smart contract that can enable us to change the code smart contract, which means if you decide not to use that code logic again, you can just decide to dispose it and deploy another one, connect it back to the main smart contracts. And normally we have the native way of doing that is through transparent closing contracts, which means you only have your storage, then the code. And that way you can only change- even though you change the code, the code cannot be- you cannot use it to scale because there's a 24 kilobytes size limit to which contracts can do. And that might initial kind of ways. But then the Diamond Standard gives you a way to write unlimited code logics for your contracts, because how it works is you have the storage and then you can- you have your presets. So each code logic is called a preset, and you can add- you store those presets in your You store the function selectors in your smart contracts, and anytime you need it, the smart contract goes to itself, looks for the function selector that was passed, and finds the logic. Which means you can have 5 to 6 different code logics all connected to one smart contract. And if you ever hit the 24 kilobyte size, you can just decide to modularize your code, which is like splitting them into modules. microcodes and all connect them to the same smart contract. And what gives us this access is because even though our contract has a code limit, it does not have a- there's no limit to storage. Storage size is unlimited. And that way you're not adding code logic to your main smart contract. You're only adding function selectors to it, which is inside the state, not the logic. And we were able to explore how it works. We were able to use it to build some contracts, and it was a very good way of- like, we really learned a good way to upgrade our smart contracts, and that's a very interesting topic.

3:44 C: Week 11, we looked at Diamond Standard, which was quite a lot. So in Diamond Standard, we were introduced to things like Diamond Storage and App Storage. We were introduced to things like the facets, the looper, the So, uh, I think the way Dynamo Standard works is just by simple, um, it uses delegate call. Delegate call works in the sense that if I'm trying to interact with my own contract, my contract doesn't have the functions. The functions is another contract. So I'm going to call that contract's function, but it's going to update my own storage. So that's how I'm going to do it. protocol works. And that's the main idea behind Diamond Standard. So Diamond Standard has something called Diamond Storage, where all app storage- but let's just break down Diamond Storage. Diamond Storage is where every storage of each of those, um, facets- now those kind of contracts, other contracts that have functionalities where their state variables are stored in Diamond Storage, and they have to be in a particular order. They were stored in the facet slot. So if, for instance, you have something variable in slot 0 in the Casula facet, it has to appear in the same format in the Dynamo storage so that if I'm calling the name on the Dynamo storage, it's going to go to slot 0 and do a delegate call on that facet and bring back the result on my own storage.

5:12 D: It was quite interesting. We did Formulas in 2020, then we started Formulas in 2021. But yes, it's 721. And then I remember our mentor, he said FC model is for basketball. We also turned it into darts, and that was literally what we did, learning the new concept about darts and the use cases and how interesting it is. So that was so educative, and I'm so, so thankful to our mentor. Team Dan for taking us through the process. What a beautiful time. Thank you.

5:50 A: Web3 Bridge Cohort 9, sponsored by Base.

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.