Giter Club home page Giter Club logo

debridge-contracts's Introduction

How White Transfers Works

The transfer of the asset from chain A to chain B goes through the followed steps:

  1. If the transfered asset isn't the native blockchain token (i.e ETH, BNB) the approve is done otherwise the transfered amount is attached to the next method.
  2. The send method of WhiteDebridge contract is called. The amount of asset is locked on the contract, the fee is charged from the amount and the Sent event is emited.
  3. The ChainLink nodes listen to the event on the WhiteDebridge contract and after 3 blocks confirmations submit the sent request identifier(submissionId) which is hash of concatination of debridgeId, amount, receiver, nonce. DebridgeId is hash of network id of the chain where the original token exists and token address on the original chain. The oracles are rewarded with LINKs immediatly after the submission.
  4. After enough confirmations from Chainlink oracles (lets say 3 out of 5) the send request status becomes confirmed.
  5. The user or any other party can call mint method of WhiteDebridge contract with the correct debridgeId, amount, receiver, nonce parameters that results into submissionId. If the submission is confirmed the wrapped asset is minted to the receiver address.

The transfer of the wrapped asset on chain B back to the original chain A to chain B goes through the followed steps:

  1. The approve to spent the wrapped asset by WhiteDebridge is done.
  2. The burn method of WhiteDebridge contract is called. The amount of the asset is burnt and the Burnt event is emited.
  3. The ChainLink nodes listen to the event on the WhiteDebridge contract and after 3 blocks confirmations submit the burnt request identifier(submissionId) which is hash of concatination of debridgeId, amount, receiver, nonce. DebridgeId is hash of network id of the chain where the original token exists and token address on the original chain. The oracles are rewarded with LINKs immediatly after the submission.
  4. After enough confirmations from Chainlink oracles (lets say 3 out of 5) the burnt request status becomes confirmed.
  5. The user or any other party can call claim method of WhiteDebridge contract with the correct debridgeId, amount, receiver, nonce parameters that results into submissionId. If the submission is confirmed the fee is transfer fee is charged and original asset is sent to the receiver address.

Note: the chainlink node can only submit up to 32 bytes per one transaction to the chain that is why debridgeId, amount, receiver, nonce can't be submitted by the node in one transaction. To solve it the hash of the parameters is used.

Aggregator

Test

yarn start-ganache &
yarn test

Ideas Backlog

  • use assets in other protocols

  • support NFT to make transfer fee lower

debridge-contracts's People

Contributors

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