New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

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

Web3BridgeWed, Oct 9, 2024, 12:00 AM

A Diamond Contract is a smart contract design pattern featuring modular facets, each handling specific functions. Utilizing a proxy pattern, calls are forwarded to relevant facets, enabling modularization and efficient upgrades. Defined by EIP-2535 (Diamond Standard), it outlines facet structure and proxy behavior. The pattern enhances gas efficiency by allowing selective updates to relevant facets, minimizing overall transaction costs. A central storage contract often manages shared storage variables to coordinate state across facets. This design facilitates flexible and upgradeable smart contract architectures, crucial for evolving blockchain applications. The Students shared their knowledge of Diamond Contract in week 11. Music by Ashot Danielyan from Pixabay

Transcript

[Music] web 3 Bridge cohort 9 sponsored by Bas hi guys this is James and I'm here to talk about my week 11 AT3 Bri so um week 11 we delve into advanced solidity and we were thought um the diamond standard and what the diamond standard is is like it's anable contract so the way um smart contract works is once you deploy them they are immutable which means you cannot change the code but now what um upgradable contract do to 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 from the code and um we now instead of putting everything as one we'll make sure we have a pointer in our M smart contract that points to the code and this way we have a function in our smart contract that can enable us 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 connecting back to the main smart contract and normally we have the native way of doing that is show transparent proy contact which means you only have your storage then the code and that way um you can only change even though you change the code the code cannot be you cannot use it to scale because um there's a 24 KOB um size limit to which contracts can do and that might limit you some kind of way but then the standard gives you a way to to write unlimited code Logics for your contract um because how it works is you have the storage and then you can you have a faet so each code logic is called a faets and um you can add you store those faets in your your you store the function selectors in your smart contract and anytime you need it the um the smart contract goes to itself looks for the function selector that was passed and finds the logic which means you can have five to six different code Logics all connected to one smart contract and if you ever eat the 24 KOB size you can just decide to modularize your Cod which is like spitting them into micro codes and all connect them to the same smart contract and what gives us this access is because even though our contract has a code limits 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 and which is inside the state not the logic and um 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 contract and that's a very interesting topic 11 we looked at Diamond standard which was quite a lot so in Diamond standard we introduced to things like diamond storage and art storage we intr things like the faets the the loop the fa C so uh I think the way that stand 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 a fun function is another contract so I'm going to call that contract function but he going to update my own storage so that's how the works and that's the main idea behind Diamond standard so Diamond standard has something called diamond storage where or storage but let me just break down diamond storage diamond storage is where every storage of each of those um facets now those contracts other Contra have functionalities where State variables are stor St in diamond storage and they have to be in particular of the way they stor in faet slot so if for instance we have name varable slot zero in faet it has to appear in the same format in the diamond story so that if I'm calling the name on The Diamond story is to go to SL zero and do a delicate SC on that faet and bring back the results of my own storage it was quite interesting we used for 20 to that for2 and remember from last also turn it into diamond and that was what we did learning the New Concept about Diamond the interest the use cases and how interesting it is so educated and I'm so so thankful to our Mentor tan for process toen thank you web 3 Bridge cohort 9 sponsored by BAS [Music] for

Automatic transcript — names and jargon may be misspelled.