← Back to home

SplitWiseD

An autonomous group payment settlement system that eliminates manual payment requests.

Problem Statement

This is an autonomous group payment settlement system that solves the friction of splitting expenses among friends, roommates, or colleagues. Think of it as "Splitwise meets autonomous AI agents" - but instead of manually sending payment requests, the system automatically detects when someone owes too much money and triggers instant cryptocurrency settlements. The core innovation is true autonomous behavior: when Alice adds a $60 dinner expense to a group, the system immediately calculates that Bob and Charlie each owe $20, and if Bob's total debt exceeds the group's threshold (say $15), an autonomous agent automatically initiates a payment request without any human clicking "send money" buttons.Autonomous Decision Making: Unlike traditional payment apps where humans must initiate settlements, this system makes financial decisions autonomously based on configurable rules. Machine-to-Machine Payments: By implementing proper x402 protocol, the system can work with AI agents, automated financial systems, or other autonomous software that needs to make payments. Crypto-Native Micropayments: Traditional payment systems can't handle $5 settlements efficiently due to fees and friction. Cryptocurrency on Polygon makes micropayments economically viable. Human-Readable Crypto: ENS integration makes cryptocurrency payments as intuitive as "pay alice.eth $20" instead of requiring users to understand blockchain addresses. Real-Time Transparency: The system broadcasts every autonomous decision through WebSocket connections, so users can see exactly when and why the agent triggered settlements. This project demonstrates how modern Web3 technologies (smart contracts, ENS, low-cost L2s, autonomous agents) can solve real-world financial friction while maintaining complete transparency and user control over autonomous behavior. It's essentially a proof-of-concept for how autonomous financial agents could work in practice.

Solution

Core Architecture & Technology StackThe project is built as amulti-layered autonomous systemthat combines blockchain smart contracts, real-time monitoring agents, and modern Web3 frontend technologies. At its core, it's designed around the principle ofautonomous decision-making- the system monitors group payment balances and automatically triggers settlements without human intervention, using ENS names to make crypto payments human-readable.Thesmart contract layerruns on Polygon Amoy testnet, written in Solidity 0.8.20. I chose Polygon specifically because micropayments require extremely low gas costs - on Ethereum mainnet, a $5 settlement could cost $20 in gas fees, making it economically unfeasible. The contract uses anevent-driven architecturewhere every expense addition emits events that trigger the autonomous agent. The settlement logic calculates optimal debt clearing paths between group members, similar to how Splitwise works but fully on-chain.The x402 Integration - HTTP 402 Payment ProtocolThe most technically interesting aspect is thex402 protocol implementation. x402 is an emerging standard that uses the HTTP 402 "Payment Required" status code for programmatic payments. When the settlement agent detects that a user's debt exceeds the threshold, it triggers an x402 flow by returning a proper 402 response with payment instructions. This is fundamentally different from traditional payment APIs - instead of redirecting to payment pages, the system providesmachine-readable payment metadatathat autonomous agents can process.The backend Express server implements true x402 semantics. When a settlement is needed, it responds withHTTP 402 Payment Requiredand includes structured payment instructions containing the recipient's ENS name, amount in USDC, and metadata about the group settlement. This enablestruly agentic behavior- an AI agent or autonomous system can receive these instructions and execute payments without human intervention.Real-Time Autonomous MonitoringThesettlement agentis built using Node.js with ethers.js for blockchain interaction. It uses adual-trigger approach: it listens for real-time blockchain events (when expenses are added) and also runs periodic scans every 30 seconds. This redundancy ensures settlements are never missed, even if the event listener fails temporarily.The agent maintainspersistent WebSocket connectionsto broadcast activity in real-time to the frontend dashboard. This creates a transparent view of autonomous decision-making - users can watch the agent detect high debts, calculate optimal settlements, and trigger payment flows. The WebSocket feed shows events like "Agent detected debt > threshold" and "Triggering x402 settlement flow" with timestamps and ENS names.ENS Integration - Making Crypto Human-ReadableRather than just displaying ENS names cosmetically, the systemdeeply integrates ENS throughout the payment flow. The smart contract stores user-provided ENS mappings, with fallback to mainnet ENS resolution. For demo purposes, I created alocal ENS storage systemthat maps demo addresses to names like "alice.eth", "bob.eth", and "charlie.eth".The ENS integration extends to the x402 payment instructions - when the system generates payment metadata, it includes both wallet addresses and resolved ENS names. This means an autonomous agent receiving a 402 response knows it needs to pay "alice.eth $20 for group settlement" rather than dealing with cryptographic addresses.Wagmi v2 + ConnectKit - Modern Web3 FrontendThe frontend usesWagmi v2 with ConnectKitfor wallet connectivity. This was particularly challenging because most tutorials and examples still use Wagmi v1 APIs. I had to implement the neweruseWriteContracthooks instead of the deprecateduseContractWrite, and useWagmiProviderinstead ofWagmiConfig.ConnectKit'sgetDefaultConfigsimplifies the Web3 setup significantly - it handles wallet detection, chain switching, and provides a polished connection modal. The configuration usesHTTP transportsfor RPC connections rather than the older provider pattern, which is more reliable and performant.

Hackathon

ETHGlobal New Delhi

2025

Contributors