MultiversX Tracker is Live!

Diamonds & Facets: Increasing Interoperability on Ethereum - A Simple Explanation

Etherum Reddit

More / Etherum Reddit 89 Views

Diamonds & Facets: Increasing Interoperability on Ethereum - A Simple Explanation

Introduction

Diamonds 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.

https://preview.redd.it/hf4dhrvq5nwa1.png?500&format=png&auto=webp&s=59017da53babe4cc494235be6a17374b68f66407

How Smart Contracts Communicate

Contracts 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 Interoperability

This 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.

https://preview.redd.it/0zihcbrv5nwa1.png?500&format=png&auto=webp&s=59c8300580fbd8874e1dc67e6493dab4eee73589

How Diamonds Work

Diamonds 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.

https://preview.redd.it/wy6uvfzy5nwa1.png?613&format=png&auto=webp&s=3198be3df96af1d249ac5bd612a4c18ae6fc1871

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 Do

Facets 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.

https://preview.redd.it/b5b2ev316nwa1.png?1000&format=png&auto=webp&s=0ff28f5fcd8db2405969543a3836d2051a80d6a0

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

submitted by /u/phillistine
[link] [comments]

Get BONUS $200 for FREE!

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