Video thumbnail

ChainShift Protocol

Revolutionary cross-chain DEX enabling seamless atomic swaps between Ethereum & Aptos

ChainShift Protocol

Created At

Unite Defi

Project Description

ChainShift is a production-ready cross-chain atomic swap protocol deployed on Ethereum Sepolia and Aptos Testnet that enables trustless token swaps without traditional bridging delays or risks.

What We Actually Built:

πŸ”— Atomic Cross-Chain Swaps Our core innovation uses Hash Time Locked Contracts (HTLCs) to guarantee atomic execution across chains. Users can swap mUSDC on Ethereum for mUSDC on Aptos (or vice versa) with cryptographic guarantees - either both sides complete or both automatically refund.

πŸ—οΈ Smart Contract Infrastructure

  • Ethereum: CrossChainSwap + CrossChainBridge contracts deployed on Sepolia
  • Aptos: Move-based generic_cross_chain_swap module deployed on testnet
  • Security: ReentrancyGuard protection, 3-hour timelocks, 32-byte secret verification

πŸ’± Dual Execution Modes

  1. Atomic Swaps: Cross-chain token swaps (mUSDC-ETH ↔ mUSDC-APT) with 1inch price optimization
  2. Bridge Transfers: Same-token transfers (mUSDC ↔ mUSDC) via liquidity pools with 0.1% fees

πŸ“Š Live Integrations

  • 1inch Fusion+ API: Real-time pricing and liquidity aggregation across 250+ DEXs
  • Dual Wallet Support: MetaMask (Ethereum) + Petra (Aptos) with live balance tracking
  • Real-time Monitoring: Transaction status across both chains with automatic updates

🎯 Proven User Flow Connect both wallets β†’ Select cross-chain tokens β†’ Get 1inch-optimized quote β†’ Execute atomic swap with single signature β†’ Monitor automatic cross-chain completion in 5-10 minutes.

πŸ§ͺ Currently Deployed Working on testnets with mUSDC-ETH and mUSDC-APT tokens, comprehensive test suite, and production-ready smart contracts awaiting mainnet deployment.

Technical Achievement: We've solved the cross-chain atomic swap challenge with actual deployed contracts, 1inch integration, and a polished interface - not just a concept, but working code.

How it's Made

πŸŒ‰ ChainShift

Bridging DeFi across chains with atomic swap technology

A novel cross-chain swap extension for 1inch Fusion+ that enables secure, trustless, bidirectional token swaps between Ethereum and Aptos networks using atomic swap protocols

🎯 Project Overview

ChainBridge Protocol implements a trustless cross-chain atomic swap mechanism that enables users to exchange tokens between Ethereum and Aptos networks while preserving the security guarantees of both blockchains. Built for the 1inch Cross-Chain Hackathon.

✨ Key Features

  • πŸ”„ Bidirectional Swaps: Seamless Ethereum ↔ Aptos token exchanges
  • βš›οΈ Atomic Transactions: All-or-nothing swap guarantees
  • πŸ”’ Hashlock/Timelock Security: Cryptographic safety mechanisms
  • πŸš€ 1inch SDK Integration: Optimal routing and liquidity
  • πŸ›‘οΈ Production Ready: Comprehensive testing and security measures
  • ⚑ Gas Optimized: Efficient transaction costs (~230K gas)

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚    Backend       β”‚    β”‚   Smart         β”‚
β”‚   (React)       │◄──►│   (Node.js)      │◄──►│   Contracts     β”‚
β”‚                 β”‚    β”‚                  β”‚    β”‚                 β”‚
β”‚ β€’ Swap Interfaceβ”‚    β”‚ β€’ Event Monitor  β”‚    β”‚ β€’ Ethereum      β”‚
β”‚ β€’ 1inch SDK     β”‚    β”‚ β€’ Cross-chain    β”‚    β”‚ β€’ Aptos (Move)  β”‚
β”‚ β€’ Multi-wallet  β”‚    β”‚   Coordination   β”‚    β”‚ β€’ Token Mgmt    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”₯ Live Deployments

Ethereum (Sepolia Testnet)

  • CrossChain Bridge: 0x4f1e1b041A9Fc9347731E893d1c06e6c8FbceDb0
  • Token Manager: 0x2A809295cc916E85cF998eA8f8559cfeB85f2e28
  • Mock USDC: 0x7a265Db61E004f4242fB322fa72F8a52D2B06664

Aptos (Testnet)

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • MetaMask (for Ethereum)
  • Petra Wallet (for Aptos)
  • Git

Installation

# Clone the repository
git clone https://github.com/Rakesh-sahoo07/chainbridge.git
cd chainbridge

# Install Ethereum dependencies
cd smart-contracts/ethereum
npm install

# Install Aptos dependencies
cd ../aptos
npm install

# Copy environment files
cp .env.example .env
# Fill in your API keys and configuration

Local Development

# Compile Ethereum contracts
cd smart-contracts/ethereum
npm run compile

# Run tests
npm test

# Compile Aptos contracts
cd ../aptos
npm run compile

πŸ§ͺ Testing Results

ChainBridge Protocol has been thoroughly tested with real on-chain transactions:

βœ… Ethereum β†’ Aptos

  • Status: βœ… FULLY OPERATIONAL
  • Live TX: 0x0375c6db...
  • Amount: 5 USDC successfully swapped

βœ… Aptos β†’ Ethereum

  • Status: βœ… VERIFIED WORKING
  • Live TX: 0xba85c646...
  • Amount: 0.05 APT successfully locked

πŸ›‘οΈ Security Tests

  • βœ… Hashlock protection verified
  • βœ… Timelock validation enforced
  • βœ… Wrong secret rejection confirmed
  • βœ… Atomic guarantees maintained

πŸ”§ Smart Contracts

Ethereum Smart Contracts

CrossChainSwapEthereum.sol

Core atomic swap functionality with hashlock/timelock mechanisms.

function initiateSwap(
    bytes32 swapId,
    bytes32 hashlock,
    address recipient,
    uint256 amount,
    address token,
    uint256 timelock
) external;

function completeSwap(bytes32 swapId, bytes32 secret) external;
function refund(bytes32 swapId) external;

TokenManager.sol

Token registry and cross-chain mapping management.

Aptos Smart Contracts

CrossChainSwapAptos.move

Move-native implementation of atomic swap protocol.

public entry fun initiate_swap(
    initiator: &signer,
    swap_id: vector<u8>,
    hashlock: vector<u8>,
    recipient: address,
    amount: u64,
    timelock: u64,
)

public entry fun complete_swap(
    completer: &signer,
    swap_id: vector<u8>,
    secret: vector<u8>,
)

βš›οΈ Atomic Swap Protocol

Phase 1: Initiation

  1. Alice generates secret and hashlock
  2. Alice locks tokens on source chain with timelock
  3. Swap details published via events

Phase 2: Commitment

  1. Bob monitors source chain events
  2. Bob verifies swap parameters
  3. Bob locks equivalent tokens on destination chain

Phase 3: Completion

  1. Alice reveals secret to claim destination tokens
  2. Secret becomes public on blockchain
  3. Bob extracts secret to claim source tokens

Phase 4: Safety

  • If timelock expires: Both parties can refund
  • Atomic guarantee: Both complete or both fail
  • No partial completion possible

πŸ› οΈ Available Commands

Ethereum Development

cd smart-contracts/ethereum

npm run compile      # Compile contracts
npm test            # Run test suite
npm run deploy:sepolia  # Deploy to Sepolia
npm run node        # Start local node

Aptos Development

cd smart-contracts/aptos

npm run compile     # Compile Move modules
npm run publish     # Publish to testnet
npm run deploy      # Initialize contracts

πŸ“ Project Structure

chainbridge/
β”œβ”€β”€ smart-contracts/
β”‚   β”œβ”€β”€ ethereum/           # Ethereum contracts (Solidity)
β”‚   β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”œβ”€β”€ test/
β”‚   β”‚   β”œβ”€β”€ scripts/
β”‚   β”‚   └── hardhat.config.js
β”‚   └── aptos/             # Aptos contracts (Move)
β”‚       β”œβ”€β”€ sources/
β”‚       β”œβ”€β”€ scripts/
β”‚       └── Move.toml
β”œβ”€β”€ frontend/              # React application (future)
β”œβ”€β”€ backend/               # Node.js services (future)
└── docs/                  # Documentation

πŸ” Security Features

  • Reentrancy Protection: OpenZeppelin ReentrancyGuard
  • Access Control: Owner-only administrative functions
  • Pausable Contracts: Emergency stop functionality
  • Input Validation: Comprehensive parameter checking
  • Timelock Validation: Secure time windows (2-48 hours)
  • Fee Management: Configurable swap fees (0.1% default)

🎯 1inch Integration

ChainBridge Protocol is designed for seamless integration with 1inch Fusion+:

  • Token Discovery: Compatible with 1inch token lists
  • Price Quotes: Leverages 1inch aggregation APIs
  • Route Optimization: Cross-chain routing algorithms
  • SDK Integration: Ready for 1inch SDK integration

πŸ›£οΈ Roadmap

  • [x] Phase 1: Smart contract development βœ…
  • [x] Phase 2: Cross-chain bridge logic βœ…
  • [x] Phase 3: Comprehensive testing βœ…
  • [ ] Phase 4: Frontend development
  • [ ] Phase 5: Backend services
  • [ ] Phase 6: Production deployment
  • [ ] Phase 7: Mainnet launch

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This is a hackathon project for demonstration purposes. While built with production-ready practices, please conduct thorough testing and security audits before any mainnet deployment.

πŸ”— Links

πŸ“ž Support

For questions and support, please open an issue in the GitHub repository or contact the development team.


Built with ❀️ for the 1inch Cross-Chain Hackathon

Bridging the future of DeFi, one atomic swap at a time. πŸŒ‰βš›οΈ

background image mobile

Join the mailing list

Get the latest news and updates