IntroductionDiamonds are a novel approach to how smart contracts can interact with one another. They enable splitting functions across multiple contracts, but keeping all of those functions accessible from the same, single place. Here's a summary with everything you should know. How Smart Contracts CommunicateContracts on Ethereum today can communicate with each other using a function named βdelegateCall.β This is a function in some contracts that calls on a function in a different contract, and executes it. How Diamonds Increase InteroperabilityThis same delegateCall method can be used to instead spread functionality over multiple smart contracts, enabling people to reuse functions in different contracts like libraries. The system for how these contracts are structured is what Diamonds introduces through EIP-2535. EIP-2535 is a framework with two types of contracts: Diamonds and Facets. The metaphor is helpful here; diamonds are the main object, and facets are their various faces. Diamonds are the directories of smart contracts, each with potentially many facets; Each smart contract referenced in a diamond is a facet. How Diamonds WorkDiamonds are contracts that only contain a fallback function. Fallback functions are most commonly used as a failsafe; when a contract receives a transaction with a request that does not match what it can do, it calls the fallback function. Since Diamonds only contain a fallback function and nothing else, every transaction it receives will be one that does not match what it can do. The Diamond can do nothing, it can only fallback. Inside a Diamondβs fallback function is the directory of Facets it can call upon. The data inside the transaction a Diamond receives determines which of these facets should be called upon. The facet is then executed, and any relevant data is stored with the Diamond contract. What Facets DoFacets are smart contracts that exist to be called by Diamonds. They provide specific functionality that can be useful to a variety of apps, and can be used by any or all of them. They contain code only, all the data they compute is stored in the Diamonds that call them. This is a summary of a full write-up from my free newsletter! Visit using the link below to learn more about blockchain, and consider signing up to be notified when a new piece is up! Stay kind. Stay curious. https://ramiwrites.substack.com/p/diamonds-and-facets-increasing-interoperability?sd=pf [link] [comments] |
You can get bonuses upto $100 FREE BONUS when you:
π° Install these recommended apps:
π² SocialGood - 100% Crypto Back on Everyday Shopping
π² xPortal - The DeFi For The Next Billion
π² CryptoTab Browser - Lightweight, fast, and ready to mine!
π° Register on these recommended exchanges:
π‘ Binanceπ‘ Bitfinexπ‘ Bitmartπ‘ Bittrexπ‘ Bitget
π‘ CoinExπ‘ Crypto.comπ‘ Gate.ioπ‘ Huobiπ‘ Kucoin.
Comments