Diamond Etherscan
Make your EIP-2535 diamond etherscan compatible.
Generate your dummy diamond at etherscan.diamonds.dev
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.
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.
- Generate your dummy implementation (via the website / cli or manually)
- Deploy your dummy implementation
- Add the EtherscanFacet to your diamond
- Set the proxy implementation to point to the deployed dummy
- Repeat any time you update the diamond
We have built a few tools to make it easier to generate a dummy implementation of your diamond.
(New!) Via the Website UI:
- Input your diamond address and network on the diamond etherscan website
- Generate your dummy diamond implementation
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
Here is a live example contract deployed to rinkeby.