Inspiration

We asked ourselves: What would JP Morgan look like if it were built from scratch for AI agents?

As autonomous agents become more capable — browsing the web, writing code, making decisions — they still can't do one fundamental thing: manage money on-chain independently. There's no bank account, no credit history, no way to earn yield, and no lending infrastructure designed for agents.

We were inspired by the Context Engineering Challenge's call to build agents that "continuously learn and improve as they operate." Traditional credit scoring (FICO) is a static, opaque system that hasn't fundamentally changed in decades. We wanted to prove that a credit model could start from zero knowledge and teach itself which on-chain behaviors predict creditworthiness — no human-labeled training data required.

What it does

Universe Bank is a full-stack on-chain banking CLI for AI agents on Base chain. It provides:

  • Wallet Management — Generate and manage wallets with AES-256-GCM encrypted private keys
  • On-Chain Identity — Register agent identities via ERC-8004 (NFT-based)
  • Autonomous Payments — HTTP 402 payments via the x402 protocol (agents pay for API access automatically)
  • DeFi Yield — Deposit USDC into Aave V3 to earn ~4-7% APY on idle funds
  • Self-Improving Credit Scoring — A sigmoid-based model (300-850 range, like FICO) that learns from loan outcomes via online stochastic gradient descent
  • Lending — Full loan lifecycle: apply, approve/deny, disburse, repay, default
  • Multi-Agent Simulation — 100 agents across 5 behavioral archetypes, 24 epochs, deterministic and reproducible

The star feature: the credit model starts completely naive (all weights = 0, approves everyone) and self-improves by observing real outcomes. After 24 epochs, the default rate drops from ~35% to ~15% — a 52% improvement — with zero human intervention.

How we built it

Architecture: Three clean layers — business logic (src/lib/), CLI commands (src/commands/), and utilities (src/utils/). ~2,000 lines of TypeScript, ES2022 ESM modules.

Credit Engine: The core is a logistic regression classifier with 6 on-chain features:

  1. Transaction count (normalized 0-100)
  2. Loan repayment rate
  3. Aave deposit amount
  4. Identity registration status (ERC-8004)
  5. Account age
  6. Average loan size

Scoring uses sigmoid(w·x + b) mapped to a 300-850 range. After each loan resolves (repaid or defaulted), we update weights via online SGD: w -= lr × (predicted - actual) × feature. An adaptive threshold raises the approval bar when defaults spike and lowers it when the model becomes too conservative.

Simulation Engine: We designed 5 agent archetypes with hidden behavioral parameters (true repay probability, loan appetite) that the credit model must learn to infer from observable on-chain features. A seeded PRNG (mulberry32) ensures deterministic reproducibility.

Tech Stack: TypeScript, viem v2 + ethers v6, Commander.js, chalk + ora for terminal UI, Base chain (low gas, Coinbase ecosystem), Aave V3, ERC-8004, x402 protocol.

Challenges we ran into

  1. Making credit scoring work without labeled data — Traditional ML needs pre-labeled datasets. We had to design a system that bootstraps from zero, accepts high initial default rates, and converges organically. The key insight was using online SGD instead of batch training — update the model after every single loan outcome.

  2. Balancing the adaptive threshold — Too aggressive and the model rejects everyone after seeing a few defaults. Too lenient and it never learns. We tuned the threshold adjustment to use a rolling average of recent default rates rather than reacting to individual outcomes.

  3. Simulation realism — Making 100 simulated agents behave realistically enough that the credit model's learned weights actually generalize. We spent significant time calibrating the 5 archetypes so that observable features (transaction count, Aave deposits) would genuinely correlate with hidden repay probability — just like in the real world.

  4. Non-interactive CLI for agents — AI agents can't type passwords interactively. We built environment variable overrides (UNIVERSE_BANK_PASSWORD, UNIVERSE_BANK_PRIVATE_KEY) so the entire banking stack works headlessly.

Accomplishments that we're proud of

  • The model actually learns the right things. After training, the highest-weighted feature is Transaction Count (+3.08), followed by Repayment Rate (+1.89), Aave Deposits (+1.19), and Identity Verified (+1.17). These match real-world intuition about creditworthiness — and the model discovered this entirely on its own.

  • 52% reduction in default rate with zero human supervision. The model goes from "approve everyone" to sophisticated risk assessment in 24 epochs.

  • End-to-end on-chain integration. This isn't a mock — wallets transact on Base, identities mint as ERC-8004 NFTs, deposits earn real Aave yield, payments flow through the x402 protocol.

  • Deterministic simulation. Same seed = same results. Anyone can verify our claims by running ubank simulate run --seed 42.

  • Clean, production-quality code. ~2,000 lines, well-structured, fully typed TypeScript. No shortcuts.

What we learned

  • Online learning is underrated. Batch ML gets all the attention, but for systems that need to bootstrap from nothing and improve continuously, online SGD is elegant and effective. One sample at a time, the model converges.

  • Feature engineering matters more than model complexity. A simple logistic regression with well-chosen on-chain features outperforms what we expected. The sigmoid + 6 features architecture is intentionally simple — and it works.

  • AI agents need financial primitives, not just APIs. Building this project made us realize how much infrastructure is missing for autonomous agents. Identity, credit, lending, payments — these are table-stakes for human finance but barely exist in the agent world.

  • Base chain is a great choice for agent infrastructure. Low gas costs mean agents can transact frequently without worrying about fees eating into their operations.

What's next for Universe Bank

  • Real on-chain credit scoring — Deploy the credit model as a smart contract so any protocol can query an agent's score on-chain
  • Cross-protocol feature aggregation — Pull features from multiple DeFi protocols (Uniswap volume, Compound history, ENS ownership) for richer credit signals
  • Agent-to-agent lending marketplace — Let agents with high credit scores lend to agents with lower scores, creating a decentralized agent credit market
  • MCP server integration — Expose Universe Bank as an MCP (Model Context Protocol) server so any AI agent framework (Claude, GPT, etc.) can use it as a tool
  • Multi-chain expansion — Extend beyond Base to Ethereum mainnet, Arbitrum, and Optimism
  • Reputation staking — Allow agents to stake tokens against their credit score, creating skin-in-the-game for good behavior

Built With

  • erc-8004-(on-chain-identity)
  • languages:-typescript-frameworks-&-libraries:-commander.js
  • x402-(http-402-payment-protocol)-other:-aes-256-gcm-(wallet-encryption)
Share this project:

Updates