zerocard-agent-kit
v1.0.1
Published
SDK for AI agents to interact with Zerocard payment API
Maintainers
Readme
zerocard-agent-kit
The Financial System for Clawdbot (OpenClaw/Moltbot)
Give your AI agent a compliant, secure financial life. This SDK connects your Clawdbot to the Zerocard network, allowing it to issue virtual cards and pay for services autonomously.
The Missing Link: A Wallet for your Agent
Clawdbot gave LLMs "arms and legs" on your computer:
- The Gateway (Ear): Listens to you via WhatsApp/Telegram.
- The Brain (LLM): Decides what to do.
- The Tools (Hands): Browses the web (Puppeteer), manages files (fs).
- The Wallet (Zerocard): This SDK. Allows the agent to spend money.
Without this, if your agent needs $20 for a Moltbook Premium subscription or a new API key, it hits a wall. With zerocard-agent-kit, it simply requests a card and completes the purchase.
Installation
npm install zerocard-agent-kitQuick Start
import { ZerocardToolHandler } from 'zerocard-agent-kit';
// 1. Initialize with your agent API key
const handler = new ZerocardToolHandler({
apiKey: 'sk_agent_xxx',
});
// 2. When AI requests payment method
const result = await handler.handleToolCall({
amount: 9.99,
merchant: 'Spotify',
});
// 3. Return the result to your AI
console.log(result.content);
// Output:
// ✅ Using existing active card (no issuance fee charged).
//
// 💳 Card Details:
// • Card ID: card_123...
// • Card Number: **** **** **** 4242
// • CVV: ***
// • Expiry: 12/2025
//
// 🔑 Secure Access Token Available
// • Token: eyJhbG...
// • Use `generateWidgetHtml(token)` to render secure card view if PAN is masked.Accessing Sensitive Data (PCI Compliance)
For agents that need to use the card for online purchases (e.g. filling a checkout form with Puppeteer), sensitive details (PAN, CVV) are masked by default.
The Bot Flow
- Check Response: You'll see
****in thepan. - Use Access Token: The response includes a secure
accessToken. - "Card" the Details: Use the token to render a secure widget in your headless browser and "click-to-copy" the details.
// Example Puppeteer Snippet in your Clawdbot
const html = zerocard.generateWidgetHtml(response.accessToken);
await page.setContent(html);
// Bots interact with the overlay elements to retrieve data
await page.click('#copy-card-pan');
const pan = await page.evaluate(() => navigator.clipboard.readText());
// Now fill the payment form
await page.type('#payment-form-card', pan);This method remains PCI compliant because the sensitive data is never transmitted directly to your backend API; it is only rendered ephemerally in the browser context.
Integration with AI Frameworks
OpenAI Function Calling
import OpenAI from 'openai';
import { ZerocardToolHandler } from 'zerocard-agent-kit';
const openai = new OpenAI();
const zerocardHandler = new ZerocardToolHandler({ apiKey: 'sk_agent_xxx' });
const tools = [ZerocardToolHandler.getToolDefinition()];
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [...],
tools,
});
// Handle tool call
if (response.choices[0].message.tool_calls) {
const toolCall = response.choices[0].message.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
const result = await zerocardHandler.handleToolCall(args);
// Send result back to AI
messages.push({
role: 'tool',
tool_call_id: toolCall.id,
content: result.content,
});
}Claude Tool Use
import Anthropic from '@anthropic-ai/sdk';
import { ZerocardToolHandler } from 'zerocard-agent-kit';
const claude = new Anthropic();
const zerocardHandler = new ZerocardToolHandler({ apiKey: 'sk_agent_xxx' });
const response = await claude.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
tools: [{
name: 'get_payment_method',
description: 'Get a virtual card to make a payment.',
input_schema: ZerocardToolHandler.getToolDefinition().function.parameters,
}],
messages: [...],
});Direct Client Usage
For custom integrations without the Tool Handler:
import { ZerocardClient } from 'zerocard-agent-kit';
const client = new ZerocardClient({
apiKey: 'sk_agent_xxx',
});
const response = await client.getPaymentMethod({
amount: 29.99,
merchant: 'Amazon',
force_new: false,
});
console.log(response.card.number);License
MIT
