This project implements a cross-chain asset transfer system where assets can be locked on one blockchain and minted as a representation on another. The system ensures security, transparency, and proof-of-transfer mechanisms.
- Lock & Mint Mechanism: Users can lock ERC-20/ERC-721 tokens on Chain A and receive a minted equivalent on Chain B.
- Proof of Transfer: Every transfer generates a receipt with a hash, timestamp, sender, receiver, and amount.
- Security Mechanisms: Replay protection, contract access controls, input validation, and gas-efficient execution.
- Wallet Connectivity: Supports MetaMask and Wallet Connect for seamless interaction.
- UI Features: Displays balances, pending transfers, successful transactions, and logs.
- Decentralized Relayers: Off-chain relayer or oracle-based verification for cross-chain communication.
- Backend: Hosted on Railway.
- Frontend: Hosted on Vercel.
- Live Demo: Please visit Live Application to test the platform.
- Demo Video: Watch our project demonstration video here: YouTube or LOOM
- Smart Contracts Deployed At:
- Sepolia (Ethereum Testnet): 0x1E05c0521B744bbf303bfD32071AE1B88F2d1bA6
- Amoy (Polygon Testnet): 0xd5d5b65Cecab2F99EAe927c6552F05aEd993832c
- Responsive and Modern UI: Designed with a user-friendly and interactive interface.
- Fetch Token Balances: Retrieves balances from both Ethereum Sepolia and Polygon Amoy testnets.
- Transaction History: Displays historical transactions from both networks.
- Live Updates: Shows real-time transaction progress and confirmation.
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Start the development server:
npm run dev
- Open your browser and navigate to
http://localhost:3000/to access the frontend UI.
- Navigate to the contracts directory:
cd contracts - Start a local Hardhat node:
npx hardhat node
- Deploy contracts to the local network:
npx hardhat run scripts/deployA.js --network localhost npx hardhat run scripts/deployB.js --network localhost
- Interact with contracts using Hardhat console:
npx hardhat console --network localhost
- Use MetaMask to connect to
http://localhost:8545/by importing one of the test accounts generated by Hardhat.
To verify the correctness of smart contracts and ensure security checks:
- Navigate to the contracts directory:
cd contracts - Run the test suite using Hardhat:
npx hardhat test - View the test results and verify that all checks pass successfully.
- Navigate to the contracts directory:
cd contracts - Start a local Hardhat node:
npx hardhat node
- Deploy contracts to the local network:
npx hardhat run scripts/deployA.js --network localhost npx hardhat run scripts/deployB.js --network localhost
- Interact with contracts using Hardhat console:
npx hardhat console --network localhost
- Use MetaMask to connect to
http://localhost:8545/by importing one of the test accounts generated by Hardhat.
Ensure you have the following installed:
- Clone the repository:
git clone https://github.com/myselfshivams/Cross-Chain-Bridge.git cd cross-chain-bridge - Install dependencies:
npm install
- Set up environment variables:
cp contracts/.env.example contracts/.env # Edit .env with appropriate values
- Navigate to the
contractsdirectory:cd contracts - Compile the contracts:
npx hardhat compile
- Deploy to testnets (Amoy & Sepolia):
npx hardhat run scripts/deployA.js --network amoy npx hardhat run scripts/deployB.js --network sepolia
- Navigate to the frontend directory:
cd frontend - Start the development server:
npm run dev
- Lock & Mint Contracts: Handle token locking and minting across chains.
- Event-Based Architecture: Facilitates transfer tracking.
- Relayer Integration: Uses oracles, signature verification, or Merkle proofs.
- Functions:
lockERC20,lockERC721,unlock,grantRelayerRole,revokeRelayerRole,_isERC721 - Events:
Locked,Unlocked - Mappings:
userNonce,lockRecords - Modifiers:
nonReentrant
- Functions:
lock,unlock,setChainBGateway,setMerkleRoot,verifySignature,splitSignature - Events:
Locked,Unlocked - Mappings:
processedNonces
- Functions:
mint,burn,setChainAGateway,setMerkleRoot,verifySignature,splitSignature - Events:
Minted,Burned - Mappings:
processedNonces
- Functions:
setRelayer,lockAsset,unlockAsset,updateOwner - Events:
AssetLocked,AssetUnlocked,RelayerUpdated,OwnershipTransferred,RelayerProcessed - Mappings:
authorizedRelayers - Modifiers:
onlyOwner,onlyRelayer
- Functions:
logTransfer,getTransferProof - Events:
TransferLogged - Mappings:
receipts
- Functions:
setGateway,mint,burn,totalSupply,balanceOf,transfer,allowance,approve,transferFrom - Mappings:
_balances,_allowances - Modifiers:
onlyGateway
- Functions:
verify,processProof,multiProofVerify,processMultiProof
- Functions:
_nonReentrantBefore,_nonReentrantAfter,_reentrancyGuardEntered - Modifiers:
nonReentrant - Lock & Mint Contracts: Handle token locking and minting across chains.
- Event-Based Architecture: Facilitates transfer tracking.
- Relayer Integration: Uses oracles, signature verification, or Merkle proofs.
- Reentrancy Protection: Prevents malicious contract calls.
- Access Controls: Restricts unauthorized contract interactions.
- Replay Attack Prevention: Ensures transactions cannot be duplicated.
- Gas Optimization: Efficient execution of transactions.
- Merkle Proofs: Implemented in
ChainAGateway.sol,ChainBGateway.sol, andMerkleProof.solfor secure transaction validation. - Modifiers: Used in
ChainGateway.sol,Lock.sol,ReentrancyGuard.sol, andTokenB.solfor restricting function execution. - OnlyOwner Restriction: Enforced in
ChainAGateway.sol,ChainBGateway.sol,ChainGateway.sol, andTokenB.solto limit administrative actions. - Reentrancy Guard: Implemented in
ReentrancyGuard.solto prevent multiple function calls. - Require Statements: Used extensively in
ChainAGateway.sol,ChainBGateway.sol,ChainGateway.sol,Lock.sol,MerkleProof.sol,ProofOfTransfer.sol, andTokenB.solto enforce conditions and security checks. - Reentrancy Protection: Prevents malicious contract calls.
- Access Controls: Restricts unauthorized contract interactions.
- Replay Attack Prevention: Ensures transactions cannot be duplicated.
- Gas Optimization: Efficient execution of transactions.
This cross-chain asset transfer system stands out due to the following unique features:
- Fully Decentralized Cross-Chain Mechanism: Unlike traditional bridges that rely on a third-party, our system uses decentralized relayers and Merkle proof verification.
- Gas Optimization Techniques: Implements efficient transaction processing to reduce gas costs on both chains.
- Multi-Layer Security: Includes reentrancy protection, signature verification, replay attack prevention, and access controls to ensure robust security.
- User-Friendly Frontend: Provides real-time transaction updates, balance fetching, and historical tracking across multiple testnets.
- Proof-of-Transfer Mechanism: Ensures transparent and auditable asset transfers by logging and verifying receipts on-chain.
- Fully Decentralized Relayers: Remove reliance on centralized infrastructure.
Watch our project demonstration video here:
You can find the complete source code to the project on GitHub: GitHub Repository
Special thanks to HACKIITK for organizing this hackathon.
We are a dedicated team of blockchain developers, cloud/backend developers, full stack developers, software engineers, and security experts passionate about decentralized finance and improving blockchain accessibility. Our goal is to create seamless, secure, and efficient blockchain solutions.