Git Product home page Git Product logo

diamond-etherscan's Introduction

Diamond Etherscan

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/libraries/generateDummyContractForEtherscan.js. This creates a noop mock of your whole diamond given your facets. Its not perfect right now, so you will probably need to make some edits to the generated mock.

The second is a Facet called DiamondEtherscanFacet.sol that should implement the EIP-1967 so you can point your diamond proxy to that implementation. Because all of your diamonds 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
  2. Deploy your dummy implementation
  3. Add the EtherscanFacet to your diamond
  4. Set the proxy implementation to point to the dummy
  5. Repeat any time you update the diamond

Example

Here is a live example contract deployed to rinkeby.

Note

This was a quick weekend hack for a proof of concept. The example isn't fully eip-1967 compliant, and how etherscan responds to updating proxy is currently untested.

Also, I'm still not sure if this should be used in production. Its technically less transparent than just directing users to Louper. Nonetheless it was pretty fun to work on. If there are any other improvements / feedbacks pls let me know.

TODO

  • support more complex types in mock script (may need to declare these)
  • fully comply to EIP-1967 with events and admin switches in the example
  • better way of generating storage position for a given parameter

diamond-etherscan's People

Contributors

zdenham avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.