Git Product home page Git Product logo

chainlink-vrf-diamond's Introduction

Chainlink VRF Diamond

Request Chainlink on-chain randomness following the diamond pattern (ERC-2535) for agile development.

Diamond Pattern

  • Allows to iterate development on-chain at low cost (including mainnet)
  • Organise app logic into modules with a facet per feature where storage can be shared or unique to the module

Facet's Storage

A facet can have a specific proxy storage (eternal storage, another diamonds stockage, etc...). This will depend on the evolution of the dApp complexity throught development lifecycle.

Solidstate Layout

An overview of the uses of each visibility layer is as follows:

folder layer contents description example
- 'internal' interface custom error, enum, struct, event & preferably modifier parent of IXyz.sol IRandomnessWritableInternal.sol, IRandomnessReadableInternal.sol
- interface function prototypes child of internal interfaces (e.g. IRandomnessWritable is IRandomnessWritableInternal) IRandomnessFallback.sol, IRandomnessReadble.sol, IRandomnessWritable.sol
fallback external any function visibility set of functions, which are only used when a callback is made to the diamond (e.g. VRFConsumerBaseV2.fulfillRandomWords). It can modify and/or read the state, which is why it can be nor in readable or writable only. RandomnessFallback.sol
readable external external or public functions set of functions that defines a module's getters RandomnessReadable.sol
writable external & internal any function visibility set of functions that defines a module's core logic; internal function always declares as xyzWritableInternal.sol RandomnessInternalWritable.sol, RandomnessWritable.sol
./ storage internal library functions, structs library for accessing and modifying storage; useful when sharing access to storage between implementation contracts that will be deployed separately (such as in the "diamond" proxy architecture) RandomnessStorage.sol

Versions

TBD

Common Specifications

TBD

v0.1.0:

v0.2.0:

v0.3.0:

v1.0.0: Mainnet release

EIPs To Consider

  • 2612: permit (off-chain approval)

Best Practices to Follow

Generics

  • Code formatter & linter: prettier, solhint, husky, lint-staged & husky
  • Foundry

Security

Be Prepared For Audits

  • Well refactored & commented code (NatSpec comment & PlantUML)
  • Unit (TDD) & integration (BDD) tests (green)
  • Paper code review (architecture & conception tests) - not required for this project
  • Use auditing tools (internally)
    • Secureum articles
    • Formal verification testing: solidity smt & else
    • Fuzz testing (echidna): (semi-)random inputs
    • Static analysers (mythril, slither)
    • Differential Testing
    • MythX (report)
    • Etc.. (rattle, etheno, surya…)
      • invariant testing
      • symbolic execution
      • mutation testing

chainlink-vrf-diamond's People

Contributors

theo6890 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.