Automated wallet health management for Monad Testnet
The Wallet Autopilot is a comprehensive wallet health management dashboard and automation system built for the Monad testnet hackathon. It allows users to monitor and automate wallet maintenance through MetaMask Smart Accounts and Delegations.
- Auto-Revoke: Automatically revokes risky or unused token allowances
- Spam Cleanup: Detects and removes spam tokens from wallets
- Dust Consolidation: Consolidates small token balances into primary assets (ETH/USDC)
- Delegated Execution: Agent performs actions on behalf of users via scoped permissions
- Health Score Dashboard: Visual wallet health metrics and real-time monitoring
Frontend (Next.js 15 + React 19)
β
Backend Agent Service (Node.js)
β
Envio Indexer (Real-time blockchain events)
β
Monad Testnet (Chain ID: 41454)
- Framework: Next.js 15 with React 19 RC
- React 19 Features: React Compiler,
useOptimistic,useTransition, Server Actions - Styling: Tailwind CSS
- Web3: Wagmi v2, Viem, MetaMask Delegation Toolkit
- State: TanStack Query (React Query)
- Runtime: Node.js with TypeScript
- Blockchain: Viem, MetaMask Delegation Toolkit
- Indexing: Envio HyperIndex
- Automation: Node-cron for scheduled checks
- API: Express.js REST API
- Network: Monad Testnet
- Account Abstraction: MetaMask Smart Accounts (Hybrid Implementation)
- Indexer: Envio for real-time event tracking
- Node.js 18+ and npm/pnpm
- MetaMask wallet with Monad testnet configured
- Monad testnet tokens (MON) from faucet
# Clone repository
git clone <your-repo-url>
cd wallet-autopilot
# Install frontend dependencies
cd frontend
npm install
# Install backend dependencies
cd ../backend
npm installFrontend (frontend/.env.local):
NEXT_PUBLIC_MONAD_RPC_URL=https://testnet.monad.xyz
NEXT_PUBLIC_MONAD_CHAIN_ID=41454
NEXT_PUBLIC_AGENT_ADDRESS=0x... # Your agent's address
NEXT_PUBLIC_API_URL=http://localhost:3001Backend (backend/.env):
MONAD_RPC_URL=https://testnet.monad.xyz
AGENT_PRIVATE_KEY=0x... # Your agent's private key
AGENT_ADDRESS=0x... # Your agent's address
ENVIO_API_URL=http://localhost:8080/v1/graphql
PORT=3001cd backend
pnpm install envio
pnpm envio devThis will start the Envio indexer locally with Hasura GraphQL API on port 8080.
Terminal 1 - Backend Agent:
cd backend
npm run devTerminal 2 - Frontend:
cd frontend
npm run devVisit http://localhost:3000 to see the app!
docker-compose upwallet-autopilot/
βββ frontend/ # Next.js 15 + React 19 app
β βββ app/ # Next.js app router
β β βββ page.tsx # Main dashboard page
β β βββ layout.tsx # Root layout with providers
β β βββ providers.tsx # Wagmi & React Query providers
β βββ components/ # React components
β β βββ WalletConnect.tsx
β β βββ HealthScore.tsx
β β βββ DelegationControls.tsx
β β βββ AllowancesTable.tsx
β βββ hooks/ # Custom React hooks
β β βββ useSmartAccount.ts
β β βββ useDelegation.ts
β β βββ useWalletHealth.ts
β βββ lib/ # Utilities and configurations
β β βββ monad.ts # Monad network config
β β βββ wagmi.ts # Wagmi configuration
β β βββ metamask.ts # MetaMask integration
β βββ types/ # TypeScript types
β
βββ backend/ # Node.js agent service
β βββ src/
β β βββ agent/ # Core agent logic
β β β βββ delegationRegistry.ts
β β β βββ monitor.ts
β β β βββ executor.ts
β β β βββ ruleEngine.ts
β β βββ services/ # External services
β β β βββ envio.ts
β β βββ config/
β β β βββ monad.ts
β β βββ index.ts # Express server
β βββ abis/ # Contract ABIs
β βββ schema.graphql # Envio GraphQL schema
β βββ envio.config.yaml # Envio configuration
β
βββ docs/ # Documentation
βββ claude.md # Project context
βββ Frontend.md # React 19 guide
βββ Metamask.md # Smart Accounts guide
βββ Envio.md # Indexer setup
βββ AgentService.md # Backend guide
βββ Monad.md # Network guide
βββ Testing.md # Testing guide
Users create a MetaMask Hybrid Smart Account on Monad testnet:
const smartAccount = await createSmartAccount(ownerAddress);Users grant scoped delegation to the agent for specific actions:
const delegation = createDelegation({
scope: {
type: 'functionCall',
targets: [tokenAddress],
selectors: ['approve(address,uint256)'],
},
to: agentAccount,
from: userSmartAccount,
});The agent monitors wallets every 5 minutes using Envio indexer data:
// Agent checks for risky approvals
const riskyApprovals = await getRiskyApprovals(walletAddress);
const actions = ruleEngine.evaluateAllApprovals(riskyApprovals);Agent executes revocations without user signatures:
await executeDelegatedTransaction({
smartAccount,
delegation,
transaction: {
to: tokenAddress,
data: revokeApprovalCalldata,
},
});# Frontend
cd frontend
npm test
# Backend
cd backend
npm testcd frontend
npm run test:e2eGET /api/wallet/:address/health- Get wallet health scoreGET /api/wallet/:address/approvals- Get all approvalsGET /api/wallet/:address/approvals/risky- Get risky approvalsPOST /api/delegation/register- Register new delegationGET /api/delegation/:address- Get delegations for wallet
query GetWalletHealth($address: String!) {
WalletHealth(where: { walletAddress: { _eq: $address } }) {
healthScore
riskyApprovals
spamTokens
}
}- Private Keys: Never commit
.envfiles. Agent's private key must be secured. - Delegation Scope: Agent only has permissions for approved actions.
- User Control: Users can revoke delegation instantly.
- Audit Trail: All automated actions are logged.
- Chain ID: 41454
- RPC: https://testnet.monad.xyz
- Explorer: https://explorer.testnet.monad.xyz
- Faucet: Get MON tokens from the official faucet
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0xa1f6',
chainName: 'Monad Testnet',
rpcUrls: ['https://testnet.monad.xyz'],
nativeCurrency: {
name: 'Monad',
symbol: 'MON',
decimals: 18
},
blockExplorerUrls: ['https://explorer.testnet.monad.xyz']
}]
});- React 19 Documentation
- MetaMask Delegation Toolkit
- Envio Documentation
- Monad Developer Docs
- Viem Documentation
- Start Envio Indexer:
cd backend && pnpm envio dev - Start Backend Agent:
cd backend && npm run dev - Start Frontend:
cd frontend && npm run dev - Connect MetaMask to Monad testnet
- Create Smart Account in the UI
- Grant Delegation to enable autopilot
- Monitor Dashboard for automated actions
React Compiler Errors:
- Ensure React 19 RC is installed
- Check ESLint plugin configuration
Smart Account Not Deploying:
- Check you have MON tokens for gas
- Verify Monad RPC URL is correct
Envio Not Indexing:
- Check contract addresses in
envio.config.yaml - Verify network configuration
Delegation Failing:
- Ensure delegation scope matches actions
- Check agent has proper permissions
This project was built for the Monad Testnet Hackathon. Contributions are welcome!
MIT
β Functional Demo:
- Working MetaMask Smart Accounts integration
- Delegation flow functional
- Deployed on Monad testnet
β Automation Impact:
- Successfully auto-revoke risky approvals
- Detect and act on spam/dust tokens
- Health score improvement demonstrated
β User Experience:
- Intuitive React 19 dashboard with instant feedback
- Clear delegation visibility and control
- Smooth transitions and optimistic updates
Built with β€οΈ for Monad Testnet Hackathon π