Git Product home page Git Product logo

bridge_eos_smart_contracts's Introduction

Waterloo bridge ETH->EOS side

Summary

Waterloo is a bi-directional ETH<->EOS decentralized relay bridge.
For the EOS->ETH side, see https://github.com/KyberNetwork/bridge_eth_smart_contracts.

Demo and Theory

Demo of relaying headers and issuing WKNC tokens
Technical blog post

Layers and Roles

The Eth->EOS Waterloo bridge ecosystem is comprised of 2 layers, where each has one or more actor types:

  • Infrastructure layer:
    • Deployer - initially deploys the bridge.
    • Relayers - relay block headers from the Ethereum chain. Each relayer runs a relay app.
  • App layer:
    • Users - run user apps in order to use the bridge data. An example of such an app is the wknc app.

shared bridge layer and user apps layer

Build sub repositories and install packages

bash scripts/build.sh

Relay App

One can use the relay app to relay Ethereum headers to EOSIO private netowrk/testnet/mainnet:

  1. Create 2 accounts - for the bridge and for a blocks relayer:
    For using existing accounts just set BRIDGE_ACCOUNT and RELAYER_ACCOUNT and skip the creation. BRIDGE_ACCOUNT=bridge
    BRIDGE_PUBLIC_KEY=EOS5CYr5DvRPZvfpsUGrQ2SnHeywQn66iSbKKXn4JDTbFFr36TRTX
    cleos create account eosio $BRIDGE_ACCOUNT $BRIDGE_PUBLIC_KEY
    RELAYER_ACCOUNT=relay
    RELAYER_PUBLIC_KEY=EOS5BVngJvx5Y1f4tdzK1bVykB79ps1ZRtDBvJo4d7kELvSta5ryN
    cleos create account eosio $RELAYER_ACCOUNT $RELAYER_PUBLIC_KEY

  2. Compile and deploy the bridge contacts
    bash scripts/compile_contracts.sh
    cleos set contract $BRIDGE_ACCOUNT contracts/Bridge Bridge.wasm --abi Bridge.abi -p $BRIDGE_ACCOUNT@active

  3. Create keypair files and a cfg file for the relay app. For example see references in scripts/local/relay_app_sample_input dir:
    deployer_keypair.json - private and public key pair for the bridge contract.
    relayer_keypair.json - private and public key pair for the relayer account.
    cfg.json - configuration parameters for the bridge.

  4. Run the relay app, pointing to your cfg file location. For example:
    node apps/relay-app/relay-app.js --cfg scripts/local/relay_app_sample_input/cfg.json --genesis=8123001 --start=8123001 --end=8123306

WKNC sample app

The WKNC sample app demonstrates how to use the bridge. It uses the stored headers data in order to validate locking of tokens on an Ethereum contract and issuing equivalent tokens on the EOS side.

  1. Create accounts and deploy contracts. See following example for a local testnet:
    bash scripts/local/issue_bringup.sh

  2. For issuing tokens there are currently 2 options:

    • Run a script which identifies lock events and calls the wknc-app to issue tokens:
      node apps/wknc-app/listen-for-lock.js

    • Alternatively, call wknc-app manually after each lock event.
      Issuing tokens is comprised of verifying a block and its receipt, as well as specifying the issue cmd:
      node apps/wknc-app/wknc-app.js --cfg scripts/local/wknc_app_sample_input/cfg.json --blockVerify=8123247 --receiptVerify=0x47d76b0a9290ad65db9e33301e9f68c45c005942ebb4c7f91503424cc599fcbf --issue

bridge_eos_smart_contracts's People

Contributors

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