GithubHelp home page GithubHelp logo

akropolisio / poc-polkadai-bridge Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 8.0 1.31 MB

(POC) Ethereum <-> Parity Substrate Blockchain bridge for self transfers of DAI Token (ERC20) to sDAI (ERC20 representation).

Home Page: https://polkadai-bridge.akropolis.io

License: MIT License

JavaScript 18.88% Rust 80.53% Shell 0.59%
substrate substrate-node ethereum erc20 dai bridge akropolis smart-contracts substrate-runtime

poc-polkadai-bridge's Introduction

riot.im

DAI Ethereum <-> Parity Substrate Bridge

Ethereum <-> Parity Substrate Blockchain bridge for self transfers of DAI Token (ERC20) to sDAI (ERC20 representation).

You can try it out in our chain:

  1. Make sure you have Ethereum and Substrate extensions. Typical choices would be:
    a. Metamask (or any other Ethereum extension) and switch it to Kovan
    b. polkadot{.js}
  2. Go here
  3. Connect with both extensions(two pop-up windows should appear)
  4. You will see that your balances from extensions should appear on the page.
  5. Transfer some Kovan test DAI to our Substrate-based chain.
  6. Transfer some DAI from our chain to your Ethereum account.

It should be pretty obvious from this point. If you hit any problems, please feel free to file an issue!

├── bridge
│   ├── ethereum
│   ├── frontend
│   └── validator - Validator service to connect Substrate to Ethereum.
├── runtime
├── scripts
├── src

Building

1. Install Rust:

curl https://sh.rustup.rs -sSf | sh

2. Install required tools:

./scripts/init.sh

3. Build the WebAssembly binary:

./scripts/build.sh

4. Build all native code:

cargo build

5. Build the validator node

Follow the validator README instructions.

6. Build frontend

Follow the frontend README instructions.

4.(Optional) Tweak configuration to use your keys and account.

Run

Start a full node:

cargo run -- --name node-name

Development

You can start a development chain with:

cargo run -- --dev

Detailed logs may be shown by running the node with the following environment variables set: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev.

If you want to see the multi-node consensus algorithm in action locally, then you can create a local testnet with two validator nodes for Alice and Bob, who are the initial authorities of the genesis chain that have been endowed with testnet units. Give each node a name and expose them so they are listed on the Polkadot telemetry site. You'll need two terminal windows open.

We'll start Alice's Substrate node first on default TCP port 30333 with her chain database stored locally at /tmp/alice. The bootnode ID of her node is QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN, which is generated from the --node-key value that we specify below:

cargo run -- \
  --base-path /tmp/alice \
  --chain=local \
  --alice \
  --node-key 0000000000000000000000000000000000000000000000000000000000000001 \
  --telemetry-url ws://telemetry.polkadot.io:1024 \
  --validator

In the second terminal, we'll start Bob's Substrate node on a different TCP port of 30334, and with his chain database stored locally at /tmp/bob. We'll specify a value for the --bootnodes option that will connect his node to Alice's bootnode ID on TCP port 30333:

cargo run -- \
  --base-path /tmp/bob \
  --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN \
  --chain=local \
  --bob \
  --port 30334 \
  --telemetry-url ws://telemetry.polkadot.io:1024 \
  --validator

Additional CLI usage options are available and may be shown by running cargo run -- --help.

How it works

Make bridge on your chain

In case you want to test it in a customise-all-the-things fashion, buckle up for some extra work!

This guide will walk you through how to create an account and how to connect to AkropolisOSChain Testnet.

  1. Run the node (previous steps, Build -> Run)

  2. Open Akropolis UI (it’s polkadotJS app working with Substrate v.1.0). You can also use Polkadot UI.

  3. Go to Settings, open Developer tab. Insert in textbox description of types (copy&paste from here) and Save it.

{
  "Count": "u64",
  "MemberId": "u64",
  "ProposalId": "u64",
  "TokenBalance": "u64",
  "TokenId": "u32",
  "Token": {
    "token_id": "u32",
    "decimals": "u16",
    "symbol": "Vec<u8>"
  },
  "Status": {
      "_enum":[
        "Pending",
        "Deposit",
        "Withdraw",
        "Approved",
        "Canceled",
        "Confirmed"
      ]
  },
    "Message": {
      "message_id": "H256",
      "eth_address": "H160",
      "substrate_address": "AccountId",
      "amount": "TokenBalance",
      "status": "Status",
      "direction": "Status"
  },
  "BridgeTransfer": {
    "transfer_id": "ProposalId",
    "message_id": "H256",
    "open": "bool",
    "votes": "MemberId"
  }
}
  1. Create an account for each validator you want to launch. Go to Accounts and generate new account(and modify validators mnemonic phrase in .env file) for each validator.

  2. Repeat step 4 for each validator in case you have more than one.

  3. Modify validators in chain_spec.rs in GenesisConfig -> bridge

  4. Repeat Build + Run instructions

  5. Launch bridge/frontend(you also might need to tweak the keys and endpoints there)

  6. Enjoy your local ERC20 Substrate <--> Ethereum bridge in your browser

poc-polkadai-bridge's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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