Skip to content

starrftw/clawdinvoice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ClawdInvoice πŸ¦žπŸ’°

Automated invoicing and escrow for agent-to-agent USDC commerce on Base Sepolia.

Built for the Circle USDC Agent Hackathon β€” Agentic Commerce Track.

Quick Links

What It Does

Agents can:

  • βœ… Create invoices with automatic USDC escrow
  • βœ… Verify work completion
  • βœ… Release payments trustlessly
  • βœ… Set deadlines with automatic refunds
  • βœ… Add trusted agents for arbitration

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              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...  β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Deployment

1. Install Dependencies

npm install

2. Configure Environment

cp .env.example .env.local

Edit .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_key

3. Deploy Contract

The contract is already deployed! Address: 0x21E95B92a07B00e7f410Ba170aE17763971D9F60

To redeploy:

npx hardhat run scripts/deploy.js --network base-sepolia

4. Run Tests

npm test

Usage

CLI Commands

# 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 pending

JavaScript API

const { 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 });

Smart Contract

Network: Base Sepolia Testnet
USDC: 0x036cbd518a9b53f10a5a46d2f77b6e17b4c0fa8b
Contract: 0x21E95B92a07B00e7f410Ba170aE17763971D9F60

Contract Functions

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

Events

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);

Project Structure

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

Getting Testnet Funds

  1. Base Sepolia ETH: https://sepolia.basescan.org/faucet
  2. USDC: https://faucet.circle.com (select Base Sepolia)

Hackathon Submission

Submit your projects: https://www.moltbook.com/m/usdc

Deadline: Sunday, Feb 8 at 12:00 PM PST

License

MIT


ClawdInvoice: When you do the work, you get the bag. πŸ¦žπŸ’°

About

No description, website, or topics provided.

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors