- Home
- Skills
- APIs & Backend
- Agent Payments Stack Bundle
Agent Payments Stack Bundle
Implement, secure, and reconcile x402 pay-per-call payments for agent-facing APIs and digital products.
$49
Agent Payments Stack Bundle
Example session with this skill installed
I need to add pay-per-call to my Node.js API using x402. How do I handle the exactly-once rule so users aren't double-charged if a request retries?
- Read your context and instructions
- Compiled the agent payments stack
To prevent double-charging in an x402 flow, you must implement an idempotent settlement layer. This ensures that if a client retries a call with the same payment signature after a successful settlement, they receive the cached response instead of a new charge.
x402 Idempotency Implementation
The following pattern uses a payment payload hash as the idempotency key to guard your handler and settlement logic.
import { getPaymentHash } from '@x402/server-utils';
async function handlePaidRequest(req, res) {
const signature = req.headers['payment-signature'];
const paymentHash = getPaymentHash(signature);
// 1. Check for existing settlement
const existingRecord = await db.ledger.findUnique({
where: { payment_hash: paymentHash }
});
if (existingRecord) {
// Return cached response from previous successful run
return res.status(200)
.set('payment-response', existingRecord.facilitator_proof)
.json(existingRecord.cached_body);
}
// 2. Verify with facilitator
const verification = await facilitator.verify(signature);
if (!verification.isValid) return res.status(402).json(verification.requirements);
// 3. Run handler and Settle
const data = await myBusinessLogic(req.body);
const settlement = await facilitator.settle(signature);
// 4. Atomic record creation
await db.ledger.create({
data: {
payment_hash: paymentHash,
facilitator_proof: settlement.proof,
cached_body: data,
settled_at: new Date()
}
});
return res.status(200)
.set('payment-response', settlement.proof)
.json(data);
}
Next steps
- Set a TTL of at least 24 hours on your idempotency store to handle delayed retries.
- Ensure your
myBusinessLogicis side-effect free or wrapped in the same transaction as the ledger record. - Verify that your 402 response includes the correct
payToaddress for your production wallet.
Connects securely to your tools. The creator never sees your data.
About this skill
Monetizing agent-facing APIs is complex. Developers face messy on-chain settlements, fragmented payment protocols, and high-stakes security risks when handling automated crypto wallets. This skill stack provides the complete blueprint for shipping, securing, and reconciling paid API products using the x402 pay-per-call standard.
What it does
- Implement x402 payments by adding HTTP-402 responses and EIP-712 signing flows to any API.
- Audit payment security with a checklist covering replay attacks, underpayment, and facilitator trust.
- Manage crypto operations through hardened runbooks for key generation, storage, and automated signing.
- Reconcile revenue using an immutable ledger model that tracks charges, settlements, and facilitator fees.
- Design token economics with a decision framework for pricing models like micropayments, credits, or subscriptions.
How it works
- Use the integration guide to wrap your existing Express, Hono, or Next.js endpoints with x402 middleware.
- Configure your wallet ops following the security runbook to ensure automated signers use scoped, hot-wallet keys.
- Apply the audit checklist to verify that your settlement logic prevents double-spending and validates token contracts.
- Export daily reconciliation reports to match on-chain settlements with logical API charges for your finance records.
Frameworks & tools
This stack supports TypeScript and JavaScript environments including Node.js, Bun, and Cloudflare Workers. It integrates with the x402 protocol, EIP-712 signing, USDC on Base, Polygon, and Arbitrum, and works with the Coinbase CDP facilitator.
Why this beats prompting it yourself
Generic LLMs often hallucinate payment protocol details or suggest insecure key handling practices. This skill provides hardened, domain-specific patterns for exactly-once settlement and idempotent refund paths that are critical for production financial systems.
Use cases
- Launch a per-call paid API that agents can use without an API key or account.
- Secure a service that pays out crypto rewards or settles on-chain transactions automatically.
- Build a transparent ledger for a team to track USDC revenue across multiple chains.
- Select the optimal pricing strategy for a bursty, autonomous agent workforce.
Known limitations
Does not support credit card processing or traditional fiat gateways. Focuses strictly on crypto/stablecoin flows (x402, USDC). Requires an external facilitator for on-chain verification.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 5 days ago
Permissions
No special permissions declared or detected
What's inside
Frequently Asked Questions
New in APIs & Backend
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.