Built for the Agentic Payments Hackathon by Locus @ YC HQ
Demo: AI agents autonomously execute invoice-backed lending using Stripe for funding, Locus for payments, and Base smart contracts for escrow.
This project bridges traditional finance (Stripe) with the crypto-native agent economy (Locus + Base):
- Users fund AI agents via Stripe Connect
- Agents operate autonomously using Anthropic SDK
- Business Agent borrows against invoice NFT collateral
- Credit Analyst Agent provides paid creditworthiness analysis
- Lender Agent executes loans via Base smart contracts
- Locus handles all agent-to-agent USDC payments
The Innovation: Stripe Connect provides fiat on-ramp for autonomous agents that transact in crypto-native economy.
┌─────────────────┐
│ Human User │
│ (Stripe Card) │
└────────┬────────┘
│ $1000 USD
▼
┌─────────────────┐ Webhook ┌──────────────────┐
│ Stripe Connect │─────────────────→ │ Convex Backend │
│ (Lender Acct) │ │ (converts 1:1) │
└─────────────────┘ └────────┬─────────┘
│
│ 1000 USDC
▼
┌──────────────────┐
│ Locus Wallet │
│ (Lender Agent) │
└────────┬─────────┘
│
┌──────────────────────────────────────┼──────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Anthropic SDK │ │ Anthropic SDK │ │ Anthropic SDK │
│ Lender Agent │◀────────────▶│ Business Agent │ │ Analyst Agent │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
│ $20 USDC (via Locus) │ │
└────────────────────────────────┼─────────────────────────┘
│
▼
┌──────────────────┐
│ Base L2 │
│ Smart Contracts │
│ • InvoiceNFT │
│ • LoanEscrow │
└──────────────────┘
- Node.js 18+
- Yarn or npm
- Stripe account (test mode)
- Anthropic API key
- Base Sepolia testnet ETH
# Clone repo
git clone <repo-url>
cd ycagentpayhack
# Install dependencies
npm install
# Copy env file
cp .env.example .env
# Edit .env with your keys# 1. Deploy smart contracts to Base Sepolia
npm run deploy:contracts
# 2. Update .env with contract addresses (printed by deploy script)
# 3. Initialize agents (creates Stripe Connect accounts)
npm run init:agents
# 4. Sync agents to Convex database
npm run sync:agents
# 5. Start development servers (Convex + Next.js)
npm run devnpm run demoycagentpayhack/
├── app/ # Next.js application
│ ├── (splash)/ # Landing page with canvas animation
│ ├── product/ # Demo application (requires sign-in)
│ └── signin/ # Authentication page
├── components/ # React UI components
├── convex/ # Convex backend (replaces Express)
│ ├── agents.ts # Agent registry management
│ ├── funding.ts # Funding API (Stripe → Locus)
│ ├── stripeWebhooks.ts # Stripe webhook handler
│ ├── locusIntegration.ts # Locus service integration
│ ├── schema.ts # Database schema
│ ├── FUNDING_API.md # API documentation
│ └── WEBHOOKS.md # Webhook documentation
├── contracts/ # Solidity smart contracts
│ ├── InvoiceNFT.sol
│ └── LoanEscrow.sol
├── src/
│ ├── agents/ # Anthropic SDK agents
│ │ ├── tools/ # Agent tool definitions
│ │ │ ├── stripe.tools.ts
│ │ │ ├── locus.tools.ts
│ │ │ ├── base.tools.ts
│ │ │ └── index.ts
│ │ └── agent-runner.ts
│ ├── services/ # Core services
│ │ ├── stripe.service.ts
│ │ ├── locus.service.ts
│ │ ├── base.service.ts
│ │ └── agent-registry.service.ts
│ ├── scripts/ # Utility scripts
│ │ ├── init-agents.ts
│ │ └── sync-agents-to-convex.ts
│ └── demo/ # Demo scripts
│ └── run-demo.ts
├── test/ # Smart contract tests
├── scripts/ # Deployment scripts
├── Docs/ # Documentation
│ ├── DEPLOYMENT.md
│ └── plans/
└── TASKS.md # Implementation tasks tracker
All API endpoints are implemented as Convex functions, not Express routes.
Action: api.funding.createFundingIntent
await convex.action(api.funding.createFundingIntent, {
agentId: "lender-001",
amountUsd: 1000
});Action: api.funding.executeFunding
await convex.action(api.funding.executeFunding, {
agentId: "lender-001",
amountUsd: 1000
});Action: api.funding.getAgentBalances
const balances = await convex.action(api.funding.getAgentBalances, {
agentId: "lender-001"
});
// Returns:
{
agentId: "lender-001",
balances: {
stripe_usd: 0,
locus_usdc: 1000,
convex_total_deposited: 1000
},
transactionCount: 1
}Query: api.funding.getAllAgentBalances
const allBalances = useQuery(api.funding.getAllAgentBalances);Query: api.funding.getAgentFundingHistory
const history = useQuery(api.funding.getAgentFundingHistory, {
agentId: "lender-001"
});Query: api.agents.getAgent
const agent = useQuery(api.agents.getAgent, {
agentId: "lender-001"
});Query: api.agents.getAllAgents
const agents = useQuery(api.agents.getAllAgents);HTTP Endpoint: /stripe/webhook
Stripe webhooks are sent to:
https://your-convex-deployment.convex.site/stripe/webhook
For local development:
http://localhost:3210/stripe/webhook
See convex/WEBHOOKS.md for details.
ERC-721 contract representing receivables (invoices).
Functions:
mint(to, debtor, amount, dueDate)- Create invoice NFTpayInvoice(tokenId)- Debtor pays invoicegetInvoice(tokenId)- View invoice details
Deployed on Base Sepolia: See .env for contract address
Escrow contract for invoice-backed loans.
Functions:
createLoan(borrower, nftContract, tokenId, principal, interest)- Create loan, lock NFTsettleLoan(loanId)- Pay off loan, release NFT
Deployed on Base Sepolia: See .env for contract address
See DEPLOYMENT.md for deployment instructions.
Each Anthropic SDK agent has access to these tools:
check_stripe_balance- Query Connect account balance
check_locus_balance- Query USDC balancetransfer_usdc- Send USDC to another agent
mint_invoice_nft- Create invoice NFT on Baseget_invoice_details- View invoice datacreate_loan- Execute loan with NFT collateral
See src/agents/tools/ for implementation.
The autonomous demo (npm run demo) executes this 8-step flow:
- Fund Lender: User transfers $1000 via Stripe → Lender's Connect account → 1000 USDC in Locus
- Mint Invoice: Business Agent creates invoice NFT ($1000, due 30 days)
- Request Loan: Business Agent requests $800 loan
- Credit Analysis: Lender pays Analyst $20 USDC for credit report
- Analyst Reviews: Credit Analyst analyzes invoice and recommends loan terms
- Execute Loan: Lender creates loan on Base (locks NFT, transfers $800 USDC)
- Pay Compute: Business Agent pays $800 USDC to compute provider
- Settle: Debtor pays invoice → $840 to Lender, $160 to Business, NFT returned
Final Balances:
- Lender: 1040 USDC (started with 1000, earned 40 interest)
- Business: 160 USDC (kept surplus after loan repayment)
- Analyst: 20 USDC (earned for credit analysis)
- Next.js 16 with App Router
- React 19
- Tailwind CSS + shadcn/ui
- Canvas animations
- Convex (replaces Express)
- TypeScript
- Real-time database
- HTTP actions for webhooks
- Anthropic SDK
- Claude Sonnet 4.5
- Custom tool definitions
- Stripe Connect (agent funding)
- Stripe Transfers (fiat → agent accounts)
- Stripe Webhooks (async notifications)
- Locus (agent-to-agent USDC payments)
- Base Sepolia (L2 testnet)
- Solidity smart contracts
- Hardhat (development)
- ethers.js v6 (blockchain interaction)
- ✅ Originality: Invoice-backed lending for AI agents
- ✅ Technical execution: Multi-layer integration (Stripe + Locus + Base + Anthropic)
- ✅ Real-world value: Solves agent funding problem
- ✅ Feasibility: Working demo with autonomous agents
- ✅ Creativity (30%): Novel use of Stripe Connect for AI agent funding
- ✅ Works in prod (20%): Real Stripe API integration with webhooks
- ✅ Real business (50%): Solves cold-start problem for agentic commerce
Why Stripe? Traditional users fund agents with credit cards (familiar UX), while agents operate in crypto-native economy (USDC on Locus). Stripe Connect bridges these worlds.
- Funding API Documentation
- Webhook Documentation
- Deployment Guide
- Design Document
- Implementation Plan
- Tasks Tracker
# Smart contract tests
npx hardhat test
# Expected: 4 passing tests# Terminal 1: Start Convex
pnpm convex dev
# Terminal 2: Forward Stripe webhooks
stripe listen --forward-to http://localhost:3210/stripe/webhook# Deploy to Base Sepolia
npm run deploy:contracts
# Verify on BaseScan
npx hardhat verify --network baseSepolia <CONTRACT_ADDRESS>Required in .env:
# Stripe
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PLATFORM_ACCOUNT_ID=acct_...
# Anthropic
ANTHROPIC_API_KEY=sk-ant-...
# Locus
LOCUS_API_KEY=...
LOCUS_API_URL=https://api.uselocus.com
# Base/Blockchain
BASE_RPC_URL=https://sepolia.base.org
PRIVATE_KEY=...
INVOICE_NFT_ADDRESS=...
LOAN_ESCROW_ADDRESS=...
# Convex
NEXT_PUBLIC_CONVEX_URL=https://your-deployment.convex.cloudSee .env.example for complete list.
- Never use real funds - This is a testnet/demo deployment
- Keep private keys secure - Never commit to git
- Use test wallets - Don't use main wallet's private key
- Verify network - Always confirm Base Sepolia (chainId: 84532)
- Mock mode available - Run demo without real API keys
- Ensure you have Base Sepolia ETH from faucet
- Check
PRIVATE_KEYin.env - Verify
BASE_RPC_URLis correct
- Run
stripe listen --forward-to http://localhost:3210/stripe/webhook - Copy webhook secret to
STRIPE_WEBHOOK_SECRET - Check Convex is running (
pnpm convex dev)
- Run
npm run init:agentsto create agents - Run
npm run sync:agentsto sync to Convex - Check
data/agent-registry.jsonexists
- Ensure all agents are initialized
- Check
.envhas all required keys - Verify contracts are deployed
This is a hackathon project. For production use:
- Replace mock Locus service with real SDK
- Add comprehensive error handling
- Implement retry logic for failed transactions
- Add monitoring and logging
- Security audit smart contracts
- Add rate limiting and abuse prevention
MIT
Built for the Agentic Payments Hackathon by Locus @ YC HQ
Team: Solo project showcasing multi-layer agent architecture
Technologies: Stripe Connect, Locus, Base, Anthropic SDK, Convex, Next.js
Timeline: 8 hours from design to working demo