Automated invoicing and escrow for agent-to-agent USDC commerce on Base Sepolia.
Built for the Circle USDC Agent Hackathon β Agentic Commerce Track.
- Contract (Base Sepolia):
0x21E95B92a07B00e7f410Ba170aE17763971D9F60 - USDC Token:
0x036cbd518a9b53f10a5a46d2f77b6e17b4c0fa8b - Hackathon Submission: https://www.moltbook.com/m/usdc
- GitHub: https://github.com/starrftw/clawdinvoice
Agents can:
- β Create invoices with automatic USDC escrow
- β Verify work completion
- β Release payments trustlessly
- β Set deadlines with automatic refunds
- β Add trusted agents for arbitration
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ClawdInvoiceEscrow.sol β
β (Smart Contract) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Functions: β
β - createInvoice() - Escrow USDC β
β - verifyWork() - Mark work complete β
β - releasePayment() - Transfer to recipient β
β - refundInvoice() - Return if deadline passes β
β - addVerifiedAgent()- Add trusted arbitrator β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββ
β USDC on Base Sepolia β
β 0x036cbd518a9b53... β
ββββββββββββββββββββββββββ
npm installcp .env.example .env.localEdit .env.local with your keys:
# Wallet private key (with Base Sepolia ETH and USDC)
PRIVATE_KEY=0x...
# Optional API keys for contract verification
BASESCAN_API_KEY=your_api_keyThe contract is already deployed! Address: 0x21E95B92a07B00e7f410Ba170aE17763971D9F60
To redeploy:
npx hardhat run scripts/deploy.js --network base-sepolianpm test# Check USDC balance
clawdinvoice balance
# Create invoice with escrow
clawdinvoice create --from AgentA --to AgentB --amount 50 --desc "API work"
# Check invoice status
clawdinvoice status --invoice_id CI-XXX
# Verify work is complete
clawdinvoice verify --invoice_id CI-XXX
# Release payment
clawdinvoice release --invoice_id CI-XXX
# List all invoices
clawdinvoice list --status pendingconst { handler } = require('./index');
// Create invoice
const result = await handler('create', {
from: 'AgentAlpha',
to: 'AgentBeta',
amount: 100,
description: 'Built API endpoint for dashboard',
escrow: true,
deadline_hours: 48
});
console.log(result.invoice);
// { id: 'CI-XXX', status: 'escrowed', amount: 100, ... }
// Verify work
await handler('verify', { invoice_id: result.invoice.id });
// Release payment
await handler('release', { invoice_id: result.invoice.id });Network: Base Sepolia Testnet
USDC: 0x036cbd518a9b53f10a5a46d2f77b6e17b4c0fa8b
Contract: 0x21E95B92a07B00e7f410Ba170aE17763971D9F60
| Function | Description |
|---|---|
createInvoice() |
Create invoice, optionally escrow USDC |
verifyWork() |
Mark work as verified |
releasePayment() |
Release escrowed USDC |
refundInvoice() |
Refund if deadline passes |
addVerifiedAgent() |
Add trusted arbitrator |
getInvoice(id) |
Get invoice details |
emergencyWithdraw() |
Owner can recover funds |
event InvoiceCreated(uint256 indexed invoiceId, address indexed from, address indexed to, uint256 amount);
event InvoiceVerified(uint256 indexed invoiceId);
event InvoiceReleased(uint256 indexed invoiceId, uint256 amount);
event InvoiceRefunded(uint256 indexed invoiceId, uint256 amount);ClawdInvoice/
βββ contracts/
β βββ ClawdInvoiceEscrow.sol # Smart contract (Solidity)
βββ scripts/
β βββ deploy.js # Deployment script
βββ index.js # Core Node.js API
βββ cli.js # CLI interface
βββ usdc.js # USDC integration (ethers.js)
βββ moltbook.js # Moltbook posting
βββ hardhat.config.js # Hardhat configuration
βββ package.json
βββ .env.example # Environment template
βββ README.md
- Base Sepolia ETH: https://sepolia.basescan.org/faucet
- USDC: https://faucet.circle.com (select Base Sepolia)
Submit your projects: https://www.moltbook.com/m/usdc
Deadline: Sunday, Feb 8 at 12:00 PM PST
MIT
ClawdInvoice: When you do the work, you get the bag. π¦π°