Home

Awesome

<p align="center"> <img width="300px; margin-top: 10px;" alt="etherscan diamond" src="https://user-images.githubusercontent.com/16373521/201745986-08ad050e-df47-4839-8ac1-2916c7f37bb6.png"> </p> <p align="center"> <b style="font-size: 30px"> Diamond Etherscan </b> <br/> <i> Make your <a href="https://eips.ethereum.org/EIPS/eip-2535" target="_blank">EIP-2535</a> diamond <a href="https://eips.ethereum.org/EIPS/eip-2535" target="_blank">etherscan</a> compatible. <br/> Generate your dummy diamond at <a target="_blank" href="https://etherscan.diamonds.dev">etherscan.diamonds.dev</a> </i> </p>

Motivation

EIP-2535 Diamond Standard is really cool. But etherscan (the most popular block explorer) doesn't support diamonds yet. Louper is a great tool that solves this issue, but many users have more experience with etherscan and might prefer to interact with the contract there.

And so, we are left with diamond etherscan, a workaround to support etherscan interactions with diamonds.

How it works

Diamond Etherscan has two components.

The first is a script to generate a "Dummy Implementation" of your diamond located at scripts/runGenerateDummy.ts. This uses the etherscan API to grab all of your facets' ABI and then generates a noop mock of your whole diamond. Note this will only work for verified facets.

The second is a Facet called DiamondEtherscanFacet.sol that implements EIP-1967 so you can point your diamond proxy to the dummy implementation. Because all of your diamond function signatures are implemented in the dummy, etherscan which knows about EIP-1967 will be able to appropriately display functions for interaction.

How to support etherscan in your diamond

  1. Generate your dummy implementation (via the website / cli or manually)
  2. Deploy your dummy implementation
  3. Add the EtherscanFacet to your diamond
  4. Set the proxy implementation to point to the deployed dummy
  5. Repeat any time you update the diamond

Generating your dummy implementation

We have built a few tools to make it easier to generate a dummy implementation of your diamond.

(New!) Via the Website UI:

<img width="973" alt="Screen Shot 2022-11-13 at 10 52 54 PM" src="https://user-images.githubusercontent.com/16373521/201594198-de153e9f-3b31-425b-bb89-13c5ed9bdef9.png">
  1. Input your diamond address and network on the diamond etherscan website
  2. Generate your dummy diamond implementation

Via the CLI

First you will need to rename .env.example to .env and add the appropriate block explorer / infura api keys. We use [UPPERCASE_NETWORK_NAME]_EXPLORER_API_KEY.

git clone https://github.com/zdenham/diamond-etherscan.git
yarn install
yarn run generate-dummy [0xyourdiamondaddress] [yourNetwork]

The dummy contract will be written to contracts/dummy/DummyDiamondImplementation.sol

Example

Here is a live example contract deployed to rinkeby.