A cross-chain bridge that facilitates transferring Donut tokens between the Sepolia Ethereum test network and the BSC testnet. This project includes both a backend (smart contracts, relayer, scripts) and a frontend (dApp interface) to demonstrate bridging functionality. When bridging Donut tokens, you will receive WDonut (wrapped Donut) tokens on the destination chain.
- Overview
- Project Structure
- Prerequisites
- Installation
- Configuration
- Deployment
- Usage
- Testing
- Folder Details
- Contributing
- License
EVM Bridge is designed to allow users to lock Donut tokens on one chain and mint a wrapped version (WDonut) on the other. The project demonstrates the concept of cross-chain bridging using:
- Donut – The primary ERC-20 token.
- WDonut – A wrapped version of Donut that represents your locked tokens on the destination chain.
- ETHBridge.sol – Manages bridging logic on the Sepolia Ethereum network.
- BSCBridge.sol – Manages bridging logic on the Binance Smart Chain testnet.
Goal: Enable developers to test bridging solutions on test networks before deploying to mainnets.
evm-bridge/
│
├── evm-bridge-backend/
│ ├── .github/
│ ├── broadcast/
│ ├── cache/
│ ├── ABI/
│ ├── db.ts
│ ├── package.json
│ ├── package-lock.json
│ ├── relayer.ts
│ ├── tsconfig.json
│ ├── types.ts
│ ├── ...
│ └── src/
│ ├── BSCBridge.sol
│ ├── ETHBridge.sol
│ ├── Token.sol (Donut)
│ ├── Wtoken.sol (WDonut)
│ └── ...
│
├── evm-bridge-frontend/
│ ├── index.html
│ ├── package.json
│ ├── package-lock.json
│ ├── tsconfig.app.json
│ ├── ...
│ └── ...
│
├── .gitignore
├── README.md
└── ...
- evm-bridge-backend – All backend code including smart contracts, scripts, and configurations for the relayer.
- evm-bridge-frontend – Frontend dApp for interacting with the bridge.
- Node.js (v14+ recommended)
- npm or yarn
- Hardhat or Foundry (if you are using Hardhat/Foundry to compile and deploy the contracts)
- MetaMask or a similar Web3-enabled wallet (for testing the dApp in a browser)
-
Clone the Repository
git clone https://github.com/your-username/evm-bridge.git cd evm-bridge -
Install Dependencies
- Backend
cd evm-bridge-backend npm install - Frontend
cd ../evm-bridge-frontend npm install
- Backend
-
Environment Variables
Create a.envfile in the evm-bridge-backend folder (and/or evm-bridge-frontend if needed) with the following keys:PRIVATE_KEY=<Your private key for deployment/testing> SEPOLIA_RPC_URL=<Sepolia network RPC URL> BSC_TESTNET_RPC_URL=<BSC testnet RPC URL> ETHERSCAN_API_KEY=<Optional, for contract verification> BSCSCAN_API_KEY=<Optional, for contract verification>Note: Make sure not to commit your private keys to version control.
-
Contract Addresses
After deploying, update the frontend.envor config files with the addresses of ETHBridge, BSCBridge, Donut, and WDonut contracts.
- Compile Contracts
cd evm-bridge-backend npx hardhat compile - Deploy to Sepolia
npx hardhat run scripts/deployEthBridge.ts --network sepolia
- Deploy to BSC Testnet
npx hardhat run scripts/deployBscBridge.ts --network bsctest
- Verify Contracts (Optional)
npx hardhat verify <CONTRACT_ADDRESS> --network sepolia npx hardhat verify <CONTRACT_ADDRESS> --network bsctest
-
Run the Backend (Relayer)
- Make sure your
.envfile is properly configured. - Start the relayer or any backend service that listens for events:
cd evm-bridge-backend npm run start:relayer
This will watch for lock events on Sepolia or BSC testnet and relay them to the other chain.
- Make sure your
-
Start the Frontend
cd ../evm-bridge-frontend npm start- This typically opens
http://localhost:3000(or another port) in your browser.
- This typically opens
-
Bridge Flow
- Lock Donut → Mint WDonut:
- On the origin chain (e.g., Sepolia), select how many Donut tokens you want to lock.
- The relayer listens for the lock event and mints WDonut on the destination chain (e.g., BSC testnet).
- Switch your wallet to the destination chain to see your newly minted WDonut tokens.
- Burn WDonut → Unlock Donut:
- On the destination chain, choose how many WDonut tokens you want to burn.
- The relayer will listen for the burn event and unlock the equivalent amount of Donut on the origin chain.
- Lock Donut → Mint WDonut:
- Unit Tests
cd evm-bridge-backend npx hardhat test
- Integration Tests
- Make sure both networks are set up.
- Ensure you have test tokens on each chain.
- Run the test suite that checks bridging functionality end-to-end.
evm-bridge-backend/.github– GitHub actions/workflows for CI/CD.evm-bridge-backend/broadcast– Deployment scripts or Hardhat artifact logs.evm-bridge-backend/cache– Compiler cache.evm-bridge-backend/ABI– Compiled ABI files for the contracts.evm-bridge-backend/src– Smart contracts and any associated libraries:BSCBridge.sol– Bridge contract for BSC testnet.ETHBridge.sol– Bridge contract for Sepolia Ethereum.Token.sol– Donut token contract.Wtoken.sol– WDonut (wrapped Donut) token contract.
evm-bridge-backend/relayer.ts– Script that listens for events on one chain and relays them to another.evm-bridge-frontend– Contains the frontend (React/Vue/Next.js, etc.) application for interacting with the contracts.
Contributions, issues, and feature requests are welcome!
Feel free to check the issues page if you want to contribute.
- Fork the project.
- Create a new branch (
git checkout -b feature/awesome-feature). - Commit your changes (
git commit -m 'Add awesome feature'). - Push to the branch (
git push origin feature/awesome-feature). - Create a new Pull Request.
This project is open-sourced under the MIT License. Feel free to use, modify, and distribute it as you see fit.
Thank you for using our bridge! 🍩✨ If you have any questions or feedback, feel free to reach out or open an issue. Happy bridging!