SplitWiseD

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

SplitWiseD

Created At

ETHGlobal New Delhi

Project Description

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.

How it's Made

Core Architecture & Technology Stack

The project is built as a multi-layered autonomous system that combines blockchain smart contracts, real-time monitoring agents, and modern Web3 frontend technologies. At its core, it's designed around the principle of autonomous decision-making - the system monitors group payment balances and automatically triggers settlements without human intervention, using ENS names to make crypto payments human-readable.

The smart contract layer runs 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 an event-driven architecture where 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 Protocol

The most technically interesting aspect is the x402 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 provides machine-readable payment metadata that autonomous agents can process.

The backend Express server implements true x402 semantics. When a settlement is needed, it responds with HTTP 402 Payment Required and includes structured payment instructions containing the recipient's ENS name, amount in USDC, and metadata about the group settlement. This enables truly agentic behavior - an AI agent or autonomous system can receive these instructions and execute payments without human intervention.

Real-Time Autonomous Monitoring

The settlement agent is built using Node.js with ethers.js for blockchain interaction. It uses a dual-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 maintains persistent WebSocket connections to 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-Readable

Rather than just displaying ENS names cosmetically, the system deeply 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 a local ENS storage system that 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 Frontend

The frontend uses Wagmi v2 with ConnectKit for wallet connectivity. This was particularly challenging because most tutorials and examples still use Wagmi v1 APIs. I had to implement the newer useWriteContract hooks instead of the deprecated useContractWrite, and use WagmiProvider instead of WagmiConfig.

ConnectKit's getDefaultConfig simplifies the Web3 setup significantly - it handles wallet detection, chain switching, and provides a polished connection modal. The configuration uses HTTP transports for RPC connections rather than the older provider pattern, which is more reliable and performant.

background image mobile

Join the mailing list

Get the latest news and updates

SplitWiseD | ETHGlobal