Git Product home page Git Product logo

dpos-contract's Introduction

Ronin DPoS Contracts

The collections of smart contracts that power the Ronin Delegated Proof of Stake (DPoS) network.

Development

Requirement

  • Node@>=14 + Solc@^0.8.0

Compile & test

  • Add Github NPM token to install packages, and then replace {YOUR_TOKEN} in .npmrc file by any arbitrary Github token with read:packages permission.

    Note: To create a new token, please refer to this article. The token must have read:packages permission.

    cp .npmrc.example .npmrc && vim .npmrc
  • Install packages

    $ yarn --frozen-lockfile
  • Install foundry libs

    $ git submodule add -b release-v0 https://github.com/PaulRBerg/prb-test lib/prb-test
    $ git submodule add -b release-v4 https://github.com/PaulRBerg/prb-math lib/prb-math
    
  • Compile contracts

    $ yarn compile
  • Run test

    $ yarn test
  • Extract storage layout

    $ yarn plugin:storage-layout [--destination <output-path>] [--override <true|false>]
    • <output-path> (optional): The path to store generated storage layout file. If not provided, the default path is layout/storage.txt.
    • --override (optional): Indicates whether to override the destination file at <output-path> if it already exists. By default, it is set to false.

Target chain to deploy

This repo contains source code of contracts that will be either deployed on the mainchains, or on Ronin chain.

  • On mainchains:
    • Governance contract: MainchainGovernanceAdmin
    • Bridge contract: MainchainGatewayV3
    • Trusted orgs contract: RoninTrustedOrganization
  • On Ronin chain:
    • Governance contract: RoninGovernanceAdmin
    • Bridge operation: RoninGatewayV3
    • Trusted orgs contract: RoninTrustedOrganization
    • DPoS contracts

Upgradeability & Governance mechanism

Except for the governance contracts and vault forwarder contracts, all other contracts are deployed following the proxy pattern for upgradeability. The TransparentUpgradeableProxyV2, an extended version of OpenZeppelin's, is used for deploying the proxies.

To comply with the governance process, in which requires all modifications to a contract must be approved by a set of governors, the admin role of all proxies must be granted for the governance contract address.

Deployment steps

  • Init the environment variables

    $ cp .env.example .env && vim .env
  • Update the contract configuration in config.ts file

  • Deploy the contracts

    $ yarn hardhat deploy --network <local|ronin-devnet|ronin-mainnet|ronin-testnet>

Documentation

See docs/README.md for the documentation of the contracts.

See docs/HACK.md for the structure of the repo.

For the contract interaction flow, please refer to DPoS Contract: Interaction Flow.

For the whitepaper, please refer to Ronin Whitepaper.

dpos-contract's People

Contributors

dependabot[bot] avatar ducthotran2010 avatar huyhuynh3103 avatar huyngopt1994 avatar minh-bq avatar nxqbao avatar tudo1403 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

klassman00

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.