Skip to content

swanandi-bhende/soft_settle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SoftSettle: AI Micro-Credit Network

Decentralized micro-credit infrastructure for AI agents using off-chain state channels, reputation scoring, and instant USDC settlements.


🎯 Quick Start

# Terminal 1: Start Backend
cd packages/backend && npm install && npm run dev

# Terminal 2: Start Frontend
cd packages/frontend && npm install && npm run dev

# Open browser
# Desktop: http://localhost:3000
# Mobile: http://your-ip:3000

Then follow DEMO_WALKTHROUGH.md for complete flow (~5 min)


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   SoftSettle Platform                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  Frontend (Next.js + RainbowKit)         Backend (Express)  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ Dashboard                      β”‚  β”‚ REST API           β”‚ β”‚
β”‚  β”‚ β”œβ”€ Agent Registration          β”‚  β”‚ β”œβ”€ /register-agent β”‚ β”‚
β”‚  β”‚ β”œβ”€ Session Monitor             β”‚  β”‚ β”œβ”€ /init-session   β”‚ β”‚
β”‚  β”‚ β”œβ”€ Micro-Auth Flow             β”‚  β”‚ β”œβ”€ /micro-auth     β”‚ β”‚
β”‚  β”‚ β”œβ”€ Payout Modal                β”‚  β”‚ β”œβ”€ /close-session  β”‚ β”‚
β”‚  β”‚ └─ Integration Status           β”‚  β”‚ └─ /integrations  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚           ⬇️                                 ⬇️            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚           Smart Contracts (Sepolia)                     β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  β”‚ ReputationManagerβ”‚  β”‚  SoftSettleChannel           β”‚  β”‚
β”‚  β”‚  β”‚ β”œβ”€ Score Updates β”‚  β”‚  (Nitrolite State Channel)   β”‚  β”‚
β”‚  β”‚  β”‚ └─ ENS Text Recordsβ”‚  β”‚ β”œβ”€ Collateral Lock         β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β”œβ”€ Session Management        β”‚  β”‚
β”‚  β”‚      Updates:          β”‚ β”œβ”€ Fund Release              β”‚  β”‚
β”‚  β”‚   vnd.soft-settle     β”‚ └─ Deficit Tracking           β”‚  β”‚
β”‚  β”‚   .score              β”‚                               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚           ↓              ↓              ↓                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          Partner Integrations (4️⃣  3️⃣  5️⃣)                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                         β”‚
β”‚  🟨 YELLOW NETWORK                  
β”‚  β”œβ”€ Nitrolite Protocol                                      β”‚   
β”‚  β”œβ”€ State Channels                                          β”‚     
β”‚  └─ Off-chain Micro-Tx                                      β”‚         
β”‚                                                             β”‚
β”‚  πŸ”΅ CIRCLE/ARC                                              β”‚
β”‚  β”œβ”€ USDC Payouts                                            β”‚  
β”‚  β”œβ”€ Wallet Management                                       β”‚        
β”‚  └─ Deficit Handling                                        β”‚                     
β”‚                                                             β”‚
β”‚  🟣 ENS                                                     β”‚
β”‚  β”œβ”€ Reputation Scoring                                      β”‚    
β”‚  β”œβ”€ Text Records                                            β”‚        
β”‚  └─ Credit Management                                       β”‚                     
β”‚                                                         
└──────────────────────────────────

πŸ“Š System Flow

User Flow                     On-Chain Events        Off-Chain State

1. Register Agent ────────→ (ENS Record Created)
   βœ… Wallet Connected
   βœ… Agent ID assigned
   βœ… Initial score: 500

2. Create Session ────────→ (Collateral Locked)
   βœ… Session ID generated      (SoftSettleChannel)
   βœ… $50 collateral held
   βœ… Nitrolite channel ready

3. Open Nitrolite ───────→ (Channel Initialized)
   βœ… Yellow SDK active           [Off-chain ready]

4. Micro-Auth (x4) ──────→  βœ… Balance updates
   βœ… Sign EIP-712                [State tracking]
   βœ… Verify signature            [No gas cost]
   βœ… Update balance              [100ms/tx]

5. Close & Settle ───────→ (Settlement Finalized)
   βœ… Final state committed       (SoftSettleChannel)
   βœ… Calculate deficit           (Circle ready)
   βœ… Update reputation           (ENS text record)
                             (ReputationManager)

Report                        Dashboard Updated
β”œβ”€ Total transferred: $20     βœ… Score: 500 β†’ 520
β”œβ”€ Deficit: $0                βœ… Deals completed: 1
└─ Status: Successful          βœ… Reputation: Rising

πŸ“¦ Project Structure

soft_settle/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ frontend/              # Next.js dashboard
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.tsx      # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.tsx  # Main demo interface
β”‚   β”‚   β”‚   β”œβ”€β”€ register.tsx   # Agent registration
β”‚   β”‚   β”‚   └── monitor.tsx    # Session monitor
β”‚   β”‚   └── components/         # Reusable UI components
β”‚   β”‚
β”‚   β”œβ”€β”€ backend/               # Express.js server
β”‚   β”‚   └── src/
β”‚   β”‚       β”œβ”€β”€ index.ts       # Main API server (8 endpoints)
β”‚   β”‚       └── integrations/
β”‚   β”‚           β”œβ”€β”€ circle.ts     # Circle API wrapper
β”‚   β”‚           β”œβ”€β”€ ens.ts        # ENS resolver
β”‚   β”‚           └── ipfs.ts       # Logging (optional)
β”‚   β”‚
β”‚   └── contracts/             # Solidity smart contracts
β”‚       β”œβ”€β”€ contracts/
β”‚       β”‚   β”œβ”€β”€ SoftSettleChannel.sol    # State channel
β”‚       β”‚   β”œβ”€β”€ ReputationManager.sol    # ENS reputation
β”‚       β”‚   └── NitroliteCore.sol        # Base protocol
β”‚       └── scripts/
β”‚           └── deploy.ts      # Sepolia deployment
β”‚
β”œβ”€β”€ DEMO_WALKTHROUGH.md        # Step-by-step demo (NEW)
└── README.md                  # This file

πŸš€ Deployment Status

Component Network Status Address
ReputationManager Sepolia βœ… Deployed 0x7C81049B93bc487a1ff4f3B00f98d3A990f84FBa
SoftSettleChannel Sepolia βœ… Deployed 0xB3A0E90884340019fFaA90e8Eb971E71396113e1
Frontend Localhost βœ… Running http://localhost:3000
Backend API Localhost βœ… Running http://localhost:4000

πŸ§ͺ Testing the Demo

Prerequisites

  • Node.js 18+
  • MetaMask or wallet (for frontend)
  • Sepolia testnet tokens (optional; demo uses mock data)

Run Demo (5 minutes)

  1. Start backend: cd packages/backend && npm run dev
  2. Start frontend: cd packages/frontend && npm run dev
  3. Open http://localhost:3000
  4. Follow DEMO_WALKTHROUGH.md

API Testing (cURL)

# Register agent
curl -X POST http://localhost:4000/api/register-agent \
  -H "Content-Type: application/json" \
  -d '{"agentId":"agent1","walletAddress":"0x123"}'

# Check integrations
curl http://localhost:4000/api/integrations

# Create session
curl -X POST http://localhost:4000/api/init-session \
  -H "Content-Type: application/json" \
  -d '{"consumerId":"agent1","providerId":"agent2","collateralAmount":50}'

πŸ“ API Reference

Endpoint Method Purpose Track
/api/register-agent POST Register agent + ENS ENS
/api/query-reputation/:id GET Fetch credit score ENS
/api/init-session POST Create session (collateral lock) Yellow
/api/yellow/open-channel POST Open Nitrolite channel Yellow
/api/micro-auth POST Off-chain payment signature Yellow
/api/close-session POST Settle + trigger payout Circle
/api/monitor-session/:id GET Live session tracking -
/api/integrations GET Integration status All

πŸŽ“ Learning Resources


πŸ“„ License

MIT


About

Submission for HackMoney 2026

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published