Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zdenham/diamond-etherscan
Make your EIP-2535 Diamond Etherscan compatible
https://github.com/zdenham/diamond-etherscan
eip-2535 ethereum solidity
Last synced: 3 months ago
JSON representation
Make your EIP-2535 Diamond Etherscan compatible
- Host: GitHub
- URL: https://github.com/zdenham/diamond-etherscan
- Owner: zdenham
- License: mit
- Created: 2022-06-11T19:31:28.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T17:58:58.000Z (10 months ago)
- Last Synced: 2024-10-18T12:18:28.324Z (4 months ago)
- Topics: eip-2535, ethereum, solidity
- Language: Solidity
- Homepage: https://etherscan.diamonds.dev
- Size: 527 KB
- Stars: 45
- Watchers: 2
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Diamond Etherscan
Make your EIP-2535 diamond etherscan compatible.
Generate your dummy diamond at etherscan.diamonds.dev
## Motivation
[EIP-2535 Diamond Standard](https://github.com/ethereum/EIPs/issues/2535) is really cool. But etherscan (the most popular block explorer) doesn't support diamonds yet. [Louper](https://louper.dev) 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`](https://github.com/zdenham/diamond-etherscan/blob/main/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`](https://github.com/zdenham/diamond-etherscan/blob/main/contracts/facets/DiamondEtherscanFacet.sol) that implements [EIP-1967](https://eips.ethereum.org/EIPS/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](https://etherscan.diamonds.dev/) / 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](https://etherscan.diamonds.dev) UI:
1. Input your diamond address and network on the diamond etherscan [website](https://etherscan.diamonds.dev/)
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](https://rinkeby.etherscan.io/address/0xc173ae57b7479b95EA9EF0B1A3C70a61e84d0F30) deployed to rinkeby.