Skip to content

metadev-xi/AnyChainSwap

Repository files navigation

ETH-To-BSC-Bridge

This is a simple Ethereum to Binance Smart Chain Bridge for minting tokens across different chains on testnet

How it Works?

We have two cross chain Smart contracts (Bridges)

  • ETH Bridge
  • BSC Bridge

We can transfer funds from one chain ( Bridge ) to other chain (Other Bridge).

From transferring from Eth to BSC , we burn tokens on Eth-bridge and mint on BSC-Bridge and vice verca. There is a Bridge API script that runs 24/7.It has an event handler for burn on Transfer Event of ETH-Bridge (We can add for BSC-Bridge too).

Whenever burn happens on Eth-Bridge , Transfer Event is fired and the API catches it. After API observe the burn event , it calls the mint function of the Binance Smart Chain Bridge and mint tokens there.

Run it

  - Make Sure you have Installed Truffle Suit
  - Clone the repository using the command `git clone https://github.com/metadev-xi/AnyChainSwap` 
  - Open the newly created repository after cloning
  - In the Truffle config , enter your own mnemonic 
  - In the scripts and migration files , enter the private keys and mnemonic by your own testwallets
  - Run `npm install` in a new terminal by pressing ` CTRL+` `
  - Run following commands for deploying Both the Bridges

Deploy Bridges

Deploy Ethereum Bridge truffle migrate --network ethereum_testnet

The output will be like as follows

image image

Deploy BSC Bridge truffle migrate --network bsc_testnet

The output will be like as follows

image

Balance Check

Check the Token Balances again by running following Commands

ETH Token Balance of the User : truffle exec scripts/balance.js --network ethereum_testnet ethereum BSC Token Balance of the User : truffle exec scripts/balance.js --network bsc_testnet bsc Arbitrum Token Balance of the User : truffle exec scripts/balance.js --network arbitrum_testnet arbitrum

same goes for optimism ,polygon and avalanche.

crossChainBalances

Run API for listening token Transfer Events

Time to run BSC Bridge for listening to the Burning event:

Type node scripts/eth-bsc-bridge.js in the terminal image

Actual Transfer

Now Open Another terminal and Run truffle exec scripts/eth-bsc-transfer.js --network ethereum_testnet

Let the transaction be completed.

Open the first terminal and you will see something like this

image

Recheck Balances

Check the Token Balances again by running following Commands

ETH Token Balance of the User : truffle exec scripts/eth-token-balance.js --network ethereum_testnet

BSC Token Balance of the User : truffle exec scripts/bsc-token-balance.js --network bsc_testnet

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published