This component provides a fully functional UI for token swapping on EVM-compatible blockchains. It supports token selection, amount input, wallet connection, token approvals (via approve()), and intent-based swaps using a smart contract.
- React / Next.js (App Router)
- TypeScript
- Wagmi + Viem (for web3 interactions)
- ShadCN/UI (UI components)
- RainbowKit (wallet connect)
- ERC20 + Custom Swap Intent Smart Contract
- ERC20 Standard ABI for token approvals
- SwapIntentABI for calling
submitIntent()on different chain-specific addresses
- Connects wallet using RainbowKit or a custom connect button
- Select source and destination tokens
- Network-aware token switching and balance fetching
- Handles token approvals before swaps
- Submits intents to a custom swap contract (multi-chain ready)
- Shows transaction success dialog with token and chain info
- Responsive UI with MAX balance shortcut
- EVM-compatible wallet (e.g., MetaMask)
- Token balances on testnet
- Contract deployed and funded for testing
-
Install dependencies:
npm install
-
Start dev server:
npm run dev
Make sure you’ve configured
wagmiand have valid network/token data in@/lib/data
- Add slippage & gas estimation
- Fetch real-time exchange rates
- Implement the OIF-Framework