Giter VIP home page Giter VIP logo

poa-bridge-contracts's Introduction

Build Status

POA bridge smart contracts

The goal of these contracts is to allow users to tokenize native POA coin into ERC20 token on ethereum mainnet. Home Bridge is a smart contract that should be deployed in POA.network Foreign Bridge is a smart contract that should be deployed in Ethereum Mainnet

Responsibilities and roles of the bridge:

  • Administrator Role(representation of a multisig contract):
    • add/remove validators
    • set daily limits on both bridges
    • set maximum per transaction limit on both bridges
    • set minimum per transaction limit on both bridges
    • upgrade contracts in case of vulnerability
    • set minimum required signatures from validators in order to relay a user's transaction
  • Validator Role :
    • provide 100% uptime to relay transactions
    • listen for Deposit events on Home bridge to mint erc20 token on Foreign bridge
    • listen for Withdraw events on Foreign bridge to unlock funds on Home Bridge
  • User role:
    • sends POA coins to Home bridge in order to receive ERC20 token on Foreign Bridge
    • sends ERC20 POA20 token on Foreign Bridge in order to receive POA coins on Home Bridge

Compilation and automated deployment

  1. Dependant packages installation
    npm install
  2. Contract compilation
    npm run compile
  3. In order to deploy contracts by Check the README.md in deploy folder.

Manual Deployment steps

It is assumed that contracts were compiled. See first two steps in the Compilation and automated deployment section.

Home Deployment(Sokol)

  1. Deploy EternalStorageProxy contract (Example address: '0x01') that will be used as Home Bridge Validators Proxy contract
  2. Deploy BridgeValidators contract (Example address: '0x02')
  3. Call upgradeTo of EternalStorageProxy that is used as Home Bridge Validators with 2 parameters:
  • 0 - version of implementation contract
  • address of implementation which is the address of step#2 BridgeValidators deployed contract (0x02)
  1. Call initialize method at Home Bridge Validators Proxy(0x01) with 2 parameters:
  • REQUIRED_NUMBER_OF_VALIDATORS. Example: 1
  • Array of validators. Example ["0x0039F22efB07A647557C7C5d17854CFD6D489eF3", "0xf052d236b8076879d86c9e4c116a068a0d420c55"]
  1. Deploy Home Bridge. Example address: 0x03
  2. Deploy EternalStorageProxy contract that will be used as Home Bridge Proxy contract. Example address: 0x04
  3. Call upgradeTo of EternalStorageProxy that is used as Home Bridge Proxy(step#6) with 2 parameters:
  • 0 - version of implementation contract
  • address of implementation which is the address of step#5 HomeBridge deployed contract. (0x03)
  1. Call initialize method at Home Bridge Proxy address with 4 parameters:
  • address of Home Bridge Validators address Proxy ( step# 1) 0x01
  • Daily Limit in wei: Example 1000000000000000000 == 1 ether
  • Maximum Per Transaction Limit in wei: Example 100000000000000000 == 0.1 ether. Should be less than Daily Limit
  • Minimum Per Transaction Limit in wei: Example 10000000000000000 == 0.01 ether. Should be less than Daily Limit and less than MaxPerTx

Foreign Deployment on Kovan

  1. Deploy POA20 contract Example(0x05)
  2. Deploy EternalStorageProxy contract that will be used as Foreign Bridge Validators Proxy contract. Example 0x06
  3. Deploy BridgeValidators contract Example 0x07
  4. Call upgradeTo of EternalStorageProxy(0x06) that is used as Foreign Bridge Validators Proxy(step#10) with 2 parameters:
  • 0 - version of implementation contract
  • address of implementation which is the address of step#11 Foreign BridgeValidators deployed contract. (0x07)
  1. Call initialize method at Foreign Bridge Validators Proxy(0x06) with 2 parameters:
  • REQUIRED_NUMBER_OF_VALIDATORS. Example: 1
  • Array of validators. Example ["0x0039F22efB07A647557C7C5d17854CFD6D489eF3", "0xf052d236b8076879d86c9e4c116a068a0d420c55"]
  1. Deploy EternalStorageProxy contract that will be used as Foreign Bridge Proxy contract. Example 0x08
  2. Deploy Foreign Bridge contract Example 0x09
  3. Call upgradeTo of EternalStorageProxy(0x08) that is used as Foreign Bridge Proxy(step#14) with 2 parameters:
  • 0 - version of implementation contract
  • address of implementation which is the address of step#15 Foreign Bridge deployed contract. (0x09)
  1. Call initialize method at Foreign Bridge Proxy(0x08) address with 5 parameters:
  • address of Foreign Bridge Validators address Proxy ( step# 10) 0x06
  • address of POA20 token contract. Step#9 0x05
  • Daily Limit in wei: Example 1000000000000000000 == 1 ether
  • Maximum Per Transaction Limit in wei: Example 100000000000000000 == 0.1 ether. Should be less than Daily Limit
  • Minimum Per Transaction Limit in wei: Example 10000000000000000 == 0.01 ether. Should be less than Daily Limit and less than MaxPerTx
  1. Call transferOwnership of POA20 contract(0x05) with 1 parameter:
  • address of Foreign Bridge Proxy (0x08) from step#14

To Flatten

Only HomeBridge and ForeignBridge contracts will be flattened.

npm run flatten

poa-bridge-contracts's People

Contributors

rstormsf avatar akolotov avatar

Watchers

James Cloos 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.