This is a Next.js project bootstrapped with create-next-app.
This application allows users to:
- Perform deposits from Bitcoin to VIA network:
- Connect with Xverse wallet,
- Initiate, sign and broadcast a deposit transaction on Bitcoin network, that will include 3 outputs:
- Output 1: Required amount of BTC is sent from the user's account to the VIA bridge address,
- Output 2: OP_RETURN output that contains l2 (EVM) address for receiving funds on VIA L2,
- Output 3: Change amount sent back to the user's wallet.
- Perform withdrawals from VIA network to Bitcoin network:
- Connect with MetaMask
- Initiate withdrawal transaction on VIA network
- Node.js 18+
- npm, yarn, pnpm, or bun
- MetaMask browser extension (for VIA network interactions)
- Xverse wallet (for Bitcoin interactions)
- Copy the environment template:
cp .env.example .env.local- Configure your environment variables:
# Set network (testnet for development, mainnet for production)
NEXT_PUBLIC_NETWORK=testnetTo use the VIA Bridge, you need to add the VIA network to your MetaMask wallet:
| Parameter | Value |
|---|---|
| Network Name | VIA Alpha Testnet |
| Chain ID | 25223 |
| RPC URL | https://via.testnet.viablockchain.dev |
| Base Token | BTC |
| Decimals | 18 |
| Block Explorer | - |
- Open MetaMask and click on the network dropdown (top center)
- Click "Add Network" or "Custom RPC"
- Fill in the network details from the table above
- Click "Save" to add the network
- Switch to VIA network
Run the development server with Turbopack:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOr run without Turbopack if you encounter issues:
npm run dev:no-turboOpen http://localhost:3000 with your browser to see the result. May use a different port if port 3000 is not available.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
npm run build
npm start- Wallet Store (
src/store/wallet-store.tsx): Centralized wallet state management - Ethereum Provider Utils (
src/utils/ethereum-provider.ts): Safe provider detection and conflict resolution - Wallet State Hook (
src/hooks/use-wallet-state.tsx): React hook for wallet interactions - Bridge Interface (
src/components/bridge-interface.tsx): Main UI component
- Provider conflict detection and resolution
- Network validation and automatic switching
- Production-safe error handling
- Security headers in production
See DEPLOYMENT.md for detailed deployment instructions including:
- Environment configuration
- Docker setup
- Platform-specific guides (Vercel, Netlify, etc.)
- Security considerations
- Multiple Wallet Providers: The app automatically handles conflicts between MetaMask, Xverse, and other wallet extensions
- Network Mismatch: Ensure your MetaMask is connected to VIA network. The app will prompt you to switch if needed.
- MetaMask Network Not Found: If MetaMask can't find the VIA network, manually add it using the configuration table above
- Connection Issues: Try refreshing the page or reconnecting your wallet
- Deposit/Withdrawal Failures: Ensure you have sufficient BTC balance and are connected to the correct networks
Development builds include detailed logging. For production debugging:
NODE_ENV=development npm start