Skip to content

zdenham/diamond-etherscan

Repository files navigation

etherscan diamond

Diamond Etherscan
Make your EIP-2535 diamond etherscan compatible.
Generate your dummy diamond at etherscan.diamonds.dev

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:

Screen Shot 2022-11-13 at 10 52 54 PM

  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.