Git Product home page Git Product logo

poa-bridge-contracts's Introduction

Join the chat at https://gitter.im/poanetwork/poa-bridge Build Status

POA Bridge Smart Contracts

These contracts provide the core functionality for the POA bridge. They implement the logic to relay assests between two EVM-based blockchain networks. The contracts collect bridge validator's signatures to approve and facilitate relay operations.

The POA bridge smart contracts are intended to work with the bridge process implemented on NodeJS. Please refer to the bridge process documentation to configure and deploy the bridge.

Bridge Overview

The POA Bridge allows users to transfer assets between two chains in the Ethereum ecosystem. It is composed of several elements which are located in different POA Network repositories:

Bridge Elements

  1. Solidity smart contracts, contained in this repository.
  2. Token Bridge. A NodeJS oracle responsible for listening to events and sending transactions to authorize asset transfers.
  3. Bridge UI Application. A DApp interface to transfer tokens and coins between chains.
  4. Bridge Monitor. A tool for checking balances and unprocessed events in bridged networks.
  5. Bridge Deployment Playbooks. Manages configuration instructions for remote deployments.

Bridge Smart Contracts Summary

Operations

Currently, the contracts support two types of relay operations:

  • Tokenize the native coin in one blockchain network (Home) into an ERC20 token in another network (Foreign).
  • Swap a token presented by an existing ERC20 contract in a Foreign network into an ERC20 token in the Home network, where one pair of bridge contracts corresponds to one pair of ERC20 tokens.

Components

The POA bridge contracts consist of several components:

  • The Home Bridge smart contract. This is currently deployed in POA.Network.
  • The Foreign Bridge smart contract. This is deployed in the Ethereum Mainnet.
  • Depending on the type of relay operations the following components are also used:
    • in NATIVE-TO-ERC mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Foreign network;
    • in ERC-TO-ERC mode: the ERC20 token (in fact, the ERC677 extension is used) is deployed on the Home network;
  • The Validators smart contract is deployed in both the POA.Network and the Ethereum Mainnet.

Bridge Roles and Responsibilities

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 UserRequestForSignature events on Home Bridge and sign an approval to relay assets on Foreign network
    • listen for CollectedSignatures events on Home Bridge. As soon as enough signatures are collected, transfer all collected signatures to the Foreign Bridge contract.
    • listen for UserRequestForAffirmation or Transfer (depending on the bridge mode) events on the Foreign Bridge and send approval to Home Bridge to relay assets from Foreign Network to Home
  • User role:
    • sends assets to Bridge contracts:
      • in NATIVE-TO-ERC mode: send native coins to the Home Bridge to receive ERC20 tokens from the Foreign Bridge, send ERC20 tokens to the Foreign Bridge to unlock native coins from the Home Bridge;
      • in ERC-TO-ERC mode: transfer ERC20 tokens to the Foreign Bridge to mint ERC20 tokens on the Home Network, transfer ERC20 tokens to the Home Bridge to unlock ERC20 tokens on Foreign networks.

Usage

Install Dependencies

npm install

Deploy

Please the README.md in the deploy folder for instructions and .env file configuration

Test

npm test

Flatten

npm run flatten

Contributing

See the CONTRIBUTING document for contribution, testing and pull request protocol.

License

License: GPL v3.0

This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.

poa-bridge-contracts's People

Contributors

akolotov avatar andogro avatar fvictorio avatar patitonar avatar rstormsf avatar

Watchers

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