Intent-based swap protocol with Account Abstraction (EIP-4337) and AI-powered route optimization
Wave 2 Status: ✅ Complete
IntentX Wave 2 delivers a comprehensive working demo showcasing the complete architecture:
- ✅ Smart Contract Scaffolds - IntentRegistry.sol & ExecutionManager.sol with full test suite
- ✅ Mock Backend API - Express server with intent engine and blockchain simulation
- ✅ Multi-Page Frontend - Dashboard, Intent Lab, and Vaults with real-time updates
- ✅ Full Integration - Frontend ↔ Backend ↔ Smart Contracts working demo
- ✅ Documentation - Comprehensive Wave 2 documentation
# Install dependencies
npm install
# Start backend server (in new terminal)
cd server
npm install
node src/index.js
# Start frontend (in project root)
npm run dev
# Run smart contract tests
cd contracts
npm install
npx hardhat testVisit http://localhost:5000 and explore:
- Dashboard - View intent statistics and recent activity
- Intent Lab - Create and execute intents with one click
- Vaults - Preview automated yield strategies
Demo Video: [To be uploaded]
See docs/WAVE2.md for complete documentation.
IntentX is a revolutionary DeFi protocol built for the BlockDAG Buildathon (DeFi Speedway Lane). Instead of manually executing swaps, users simply specify their intent (e.g., "swap 1 ETH to USDC at the best rate"), and the protocol automatically finds the optimal path and executes it using Account Abstraction and AI-assisted logic.
- 🎯 Intent-Based Trading - Describe what you want, we execute it optimally
- ⚡ Account Abstraction (EIP-4337) - Gasless transactions with signature verification
- 🤖 AI-Powered Execution - Automatic route optimization and timing
- 🔒 Slippage Protection - Maximum 2% slippage enforcement
- 📊 Real-Time Analytics - Track intents, volumes, and success rates
- 🎨 Modern UI - Dark mode, smooth animations, futuristic design
IntentX.sol - Core protocol contract
createIntent()- Create a new swap intent with signature verificationexecuteIntent()- Execute intent with optimal routing (executor only)cancelIntent()- Cancel pending intents- Account Abstraction integration for gasless transactions
- Slippage protection (<2%)
- Protocol fee mechanism (0.3%)
MockERC20.sol - Test tokens for development
API Endpoints:
POST /api/intents- Create new intentGET /api/intents/:userAddress- Get user's intentsPOST /api/intents/:id/cancel- Cancel intentPOST /api/intents/:id/execute- Execute intent (bot only)GET /api/analytics- Get protocol analytics
Intent Executor Bot:
- Monitors pending intents every 5 seconds
- Checks market conditions and optimal execution timing
- Automatically executes when conditions are met
- Verifies slippage protection
Components:
- Wallet connection (MetaMask integration)
- Swap interface with token selection
- Intent dashboard (Pending/Executed/Cancelled)
- Analytics dashboard
- Dark/Light mode support
Tech Stack:
- React 18 + TypeScript
- TailwindCSS + Shadcn UI
- TanStack Query for data fetching
- Ethers.js v6 for Web3 interactions
- Framer Motion for animations
- Node.js 20+
- MetaMask or compatible wallet
- BlockDAG testnet RPC access (or use local development)
# Clone the repository
git clone https://github.com/yourusername/intentx.git
cd intentx
# Install dependencies
npm install
# Install Hardhat dependencies
npm install hardhat @nomicfoundation/hardhat-toolbox @openzeppelin/contracts dotenv
# Set up environment variables
cp .env.example .env
# Edit .env with your configurationCreate a .env file in the root directory:
# Blockchain Configuration
BLOCKDAG_RPC_URL=https://rpc-testnet.blockdag.network
PRIVATE_KEY=your_private_key_here
# Frontend Configuration (create .env.local in client/)
VITE_INTENTX_ADDRESS=0x...
VITE_RPC_URL=https://rpc-testnet.blockdag.network
# Optional: Token Addresses
VITE_USDC_ADDRESS=0x...
VITE_USDT_ADDRESS=0x...
VITE_WBTC_ADDRESS=0x...
VITE_DAI_ADDRESS=0x...# Compile smart contracts
npx hardhat compile
# Deploy contracts to local network
npx hardhat node # In one terminal
npx hardhat run scripts/deploy.ts --network localhost # In another terminal
# Start the development server
npm run devThe application will be available at http://localhost:5000
# Make sure .env is configured with BlockDAG RPC URL and private key
npx hardhat run scripts/deploy.ts --network blockdagThe deployment script will output contract addresses. Add them to your .env.local file.
The application is configured to work with Replit Deployments or any static hosting service.
# Build for production
npm run build
# The built files will be in the dist/ directoryClick "Connect Wallet" in the header to connect your MetaMask wallet to the BlockDAG testnet.
- Select source and target tokens
- Enter amount to swap
- Adjust slippage tolerance (default: 1%)
- Click "Create Intent"
- Sign the message for Account Abstraction
- View your intents in the Intent Dashboard
- Pending intents will be automatically executed by the bot (usually within 10-30 seconds)
- See real-time status updates
- View executed amounts and rates
Track your trading activity:
- Total intents created
- Executed swaps
- Total volume traded
- Success rate
npx hardhat test- Create Intent: Submit a swap intent and verify it appears in the dashboard
- Executor Bot: Wait for the bot to execute the intent (~10-30 seconds)
- Cancel Intent: Try cancelling a pending intent
- Analytics: Verify metrics update after transactions
Key Functions:
function createIntent(
address sourceToken,
address targetToken,
uint256 sourceAmount,
uint256 minTargetAmount,
uint256 slippage,
bytes memory signature
) external returns (bytes32);
function executeIntent(
bytes32 intentId,
uint256 targetAmount
) external;
function cancelIntent(bytes32 intentId) external;Events:
event IntentCreated(bytes32 indexed intentId, address indexed user, ...);
event IntentExecuted(bytes32 indexed intentId, address indexed executor, ...);
event IntentCancelled(bytes32 indexed intentId, address indexed user);- ✅ ReentrancyGuard on all state-changing functions
- ✅ Signature verification for Account Abstraction
- ✅ Slippage protection (max 2%)
- ✅ SafeERC20 for token transfers
- ✅ Access control for executor functions
The executor bot runs automatically when the server starts. It:
- Monitors pending intents every 5 seconds
- Analyzes market conditions and optimal timing
- Executes intents when conditions are met
- Verifies slippage protection before execution
Edit server/executor-bot.ts to customize:
- Check interval (default: 5 seconds)
- Execution criteria (default: after 10 seconds)
- Exchange rate sources
- Slippage tolerance
IntentX uses a modern, futuristic design inspired by leading DeFi platforms:
- Colors: Primary (Blue), Gradients (Purple to Cyan)
- Typography: Inter font family
- Spacing: Consistent 4px grid system
- Components: Shadcn UI + custom components
- Animations: Smooth transitions with Framer Motion
- Dark Mode: Full support with system preference detection
POST /api/intents
Content-Type: application/json
{
"userAddress": "0x...",
"sourceToken": "ETH",
"targetToken": "USDC",
"sourceAmount": "1.5",
"minTargetAmount": "2775.00",
"slippage": "1",
"signature": "0x..."
}GET /api/intents/:userAddressPOST /api/intents/:id/cancelGET /api/analytics?userAddress=0x...| Layer | Technology |
|---|---|
| Blockchain | BlockDAG (EVM-compatible) |
| Smart Contracts | Solidity ^0.8.20 |
| Backend | Node.js, Express, TypeScript |
| Frontend | React 18, TypeScript, Vite |
| Styling | TailwindCSS, Shadcn UI |
| Web3 | Ethers.js v6 |
| State Management | TanStack Query |
| Development | Hardhat, ESLint, TypeScript |
This project was built for the BlockDAG Buildathon - DeFi Speedway Lane.
- ✅ Full-stack DeFi application
- ✅ Smart contracts with Account Abstraction
- ✅ Intent-based swap mechanism
- ✅ Automated executor bot
- ✅ Real-time analytics dashboard
- ✅ Production-ready UI/UX
- ✅ Deployment scripts
- ✅ Comprehensive documentation
MIT License - see LICENSE file for details
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Project built by: [Abdulganiyyu Mustapha Muhammad]
- GitHub: @itzsoftwaredevops1005-source
- Twitter: @AbdulganiyyuMM
Built with ❤️ for the BlockDAG Buildathon