Giter Club home page Giter Club logo

erc20-bridge-smart-contract's Introduction

Hardhat Bridge Project

Bridge Frontend: https://github.com/ilchovski98/ERC20-bridge-frontend Bridge Backend: https://github.com/ilchovski98/ERC20-bridge-backend

About the project

The implementation of the bridge allows for the deployment and interaction on 3+ chains.

After the deposit of an ERC20 token, the user can claim a wrapped version of the token on any of the other chains. The bridge uses a lock/mint/burn/release mechanism where the original is transfered to the bridge and on another chain a wrapped version of the token is deployed/minted to the user address. If the wrapped ERC20 is transfered to a 3rd chain, the tokens will be burned and new will be minted on the destination chain.

The tokens will not be wrapped more than once and by returning the wrapped tokens on the source chain, the original ones can be released.

The bridge relies on a centralised entity (the deployer of the bridge contracts) to listen for the emited events and to provide the user with the needed signatures in order to execute the claim function (to mint new tokens or to release existing ones).

The gas for the transactions is paid by the user that interacts with the bridge. This includes the deployment of the wrapped token contracts if they are not already deployed.

The bridge supports standard ERC20 tokens through it's deposit() function. Before calling the deposit function the user must approve the bridge to transfer the tokens they want to deposit. This happens in two seperate transactions. ERC20 tokens that implement permits (EIP 2612) are also supported by calling the depositWithPermit() function, where the approval and the transfer are done in one transaction.

Deploying Guide

  1. Create .env file with the needed variables as in .env.example
  2. Make sure that line 225 in contracts/Bridge.sol is uncommented (it is commented because tests are done on 1 chain at the moment)
  3. Use the hardhat tasks "deploy-bridge" and "deploy-permitERC20" to deploy the bridge and some ERC20 tokens on the desired networks (use --help to identify what arguments each task needs)
  4. Make sure to unpause the bridge contracts after deployment
  5. Enjoy!

Deployments on Sepolia

Bridge contract:

Random Coin (permitERC20):

Doge Coin (permitERC20):

Cat Coin (permitERC20):

Deployments on Goerli

Bridge contract:

Dino Coin (permitERC20):

Bird Coin (permitERC20):

Deployments on Mumbai

Bridge contract:

Iron Man Coin (permitERC20):

erc20-bridge-smart-contract's People

Contributors

ilchovski98 avatar

Stargazers

Rumena Staneva avatar

Watchers

 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.