Buyer Agent SDK
npm install @katanga/sdk-buyer
How It Works
The buyer agent executes a 4-phase autonomous purchasing loop:
DISCOVERY — Scan on-chain listings by category, price, region
EVALUATION — Score candidates: price (40%) + reputation (35%) + speed (25%)
PURCHASE — Approve token, create escrow, lock payment
MONITOR — Watch for shipment, auto-confirm delivery
SDK Usage
import { BuyerAgent } from "@katanga/sdk-buyer";
const agent = new BuyerAgent({
publicClient,
walletClient,
marketAddress: "0x2c87D6ce...",
escrowAddress: "0x5a1BEB64...",
reputationAddress: "0x8ec32486...",
paymentToken: "0xC1A5B415...",
minReputationScore: 10,
});
// Discover and rank listings
const results = await agent.discover({
category: "electronics",
maxPriceUSD: 100,
shippingRegion: 840, // US
});
// Purchase the top result
const escrowId = await agent.purchase(
results[0].listing.id, // listing ID
1n, // quantity
"123 Main St, Austin TX", // shipping details
parseUnits("50", 6), // payment amount (USDT0)
);
// Confirm delivery
await agent.confirmDelivery(escrowId);CLI
# Environment variables BUYER_PRIVATE_KEY=0x... CATEGORY=electronics MAX_PRICE=100 MIN_REPUTATION=0 SHIPPING_REGION=840 PAYMENT_AMOUNT=1000000 # 1 USDT0 # Run buyer agent pnpm cli # Monitor and auto-confirm delivery pnpm monitor