Web Frontend

React-based user interface for cross-chain atomic swap operations

Frontend Features

Modern React application with comprehensive swap functionality

Wallet Integration

Seamless integration with MetaMask for Ethereum and Internet Identity for ICP.

Swap Interface

Intuitive interface for creating and managing cross-chain atomic swaps.

Real-time Updates

Live updates on swap status, exchange rates, and transaction progress.

Security Features

Built-in security validation and transaction confirmation dialogs.

Responsive Design

Mobile-friendly interface that works on all devices and screen sizes.

Transaction History

Complete history of all swaps with detailed status tracking.

Technology Stack

Modern web technologies for optimal user experience

React

Component-based UI library

TypeScript

Type-safe JavaScript

CSS3

Modern styling

Web3

Blockchain integration

Core Components

Modular React components for different aspects of the swap interface.

WalletConnect

Handles wallet connections for both Ethereum and ICP

ExchangeButton

Main swap execution component

AmountInput

Input component for swap amounts

CurrencySelector

Currency selection dropdown

ExchangeRate

Real-time exchange rate display

NetworkInfo

Network status and information

Custom Hooks
// useExchange.ts - Main swap logic
export const useExchange = () => {
  const [swapState, setSwapState] = useState();
  const [loading, setLoading] = useState(false);
  
  const createSwap = async (params: SwapParams) => {
    // Swap creation logic
  };
  
  return { swapState, loading, createSwap };
};

// useMetaMask.ts - Ethereum wallet integration
export const useMetaMask = () => {
  const [account, setAccount] = useState();
  const [chainId, setChainId] = useState();
  
  const connect = async () => {
    // MetaMask connection logic
  };
  
  return { account, chainId, connect };
};
Key Features
  • MetaMask integration
  • Internet Identity support
  • Real-time rate updates
  • Transaction tracking
  • Error handling
  • Mobile responsive

Setup Guide

Get the frontend running in minutes

Prerequisites
  • Node.js 16+ and npm
  • MetaMask browser extension
  • Internet Identity (for ICP)
  • Ethereum testnet access
Installation
cd frontend
npm install
cp env.example .env
# Configure environment variables
Development
npm start
# Start development server
npm run build
# Build for production
Deployment
npm run build
dfx deploy
# Deploy to Internet Computer
npm run deploy:ic
# Deploy to IC mainnet

Usage Examples

Common frontend integration patterns

Wallet Connection
import { useMetaMask } from './hooks/useMetaMask';
import { useInternetIdentity } from './hooks/useInternetIdentity';

const App = () => {
  const { account, connect: connectEth } = useMetaMask();
  const { identity, login: loginICP } = useInternetIdentity();
  
  return (
    
); };
Swap Creation
import { useExchange } from './hooks/useExchange';

const SwapComponent = () => {
  const { createSwap, loading, swapState } = useExchange();
  
  const handleSwap = async () => {
    await createSwap({
      fromCurrency: 'ETH',
      toCurrency: 'ICP',
      amount: '1.0',
      recipient: 'user-address'
    });
  };
  
  return (
    
  );
};