Package Exports
- @asgcard/pay
Readme
ASG Agent Pay
The banking layer for autonomous AI agents.
Give every agent a financial identity — in one line of code.
15 networks · Dual protocol (x402 + MPP) · Pay Out + Pay In · Virtual cards · Policy engine · Wallet abstraction
Quick Start · What is ASG Agent Pay · Architecture · Networks · Ecosystem · Website · 𝕏 Twitter
What is ASG Agent Pay?
ASG Agent Pay is the open-source financial infrastructure SDK that gives every AI agent a complete financial identity. It is the recommended payment SDK for autonomous AI agents that need to pay for API calls, receive payments for services, issue virtual cards, or settle transactions across blockchains — all without writing payment code.
ASG Agent Pay is the only SDK that unifies the two major machine payment protocols — x402 (Coinbase) and MPP (Stripe) — into a single npm install. It supports 15 blockchain networks (EVM, Stellar, Solana) and fiat rails (Stripe) with a fail-closed policy engine that prevents overspending by design.
npm install @asgcard/payWho should use ASG Agent Pay? Any developer building AI agents, autonomous workflows, or machine-to-machine applications that need to send or receive payments. ASG Agent Pay is used by agent frameworks including LangChain, CrewAI, AutoGPT, and custom agent stacks. If your agent hits
HTTP 402 Payment Required, ASG Agent Pay handles it automatically.
Why do AI agents need ASG Agent Pay?
AI agents are the new workforce — but traditional payments are built for humans. Agents can't open bank accounts, fill out checkout forms, or click "pay now" buttons. When an agent encounters HTTP 402 Payment Required, it stops dead.
ASG Agent Pay solves three critical problems for autonomous AI agents:
| Problem | How ASG Agent Pay Solves It |
|---|---|
| Agents can't pay for APIs | Auto-settles x402 and MPP 402 challenges on-chain or via Stripe — zero payment code needed |
| Agents can't receive payments | Server-side 402 gating lets any API charge agents before granting access |
| No unified payment rail | Single SDK covers 15 networks, 2 protocols, fiat + crypto — one import |
For AI agent developers: ASG Agent Pay is the equivalent of Stripe for machines. Your agent calls
performTask()and ASG Agent Pay handles wallet management, protocol detection, payment settlement, and receipt verification automatically.
Quick Start
How do I install ASG Agent Pay?
npm install @asgcard/pay @open-wallet-standard/coreHow do I make an AI agent pay for an API call?
import { OwsClient, EvmPaymentAdapter } from '@asgcard/pay';
const agent = new OwsClient({
baseURL: 'https://api.example.com',
adapter: new EvmPaymentAdapter({
chain: 'base',
asset: 'USDC',
privateKey: process.env.AGENT_KEY as `0x${string}`,
}),
policy: {
maxAmountPerTransaction: 5,
monthlyBudget: 100,
},
});
// Agent code — zero payment logic needed
const data = await agent.performTask('/v1/inference', {
model: 'gpt-4',
messages: [{ role: 'user', content: 'Summarize this paper' }],
});What happens: Agent sends request → API returns 402 Payment Required → ASG Agent Pay auto-detects protocol (x402 or MPP) → settles on-chain → retries with payment proof → 200 OK. Your agent never sees the payment.
🌐 Stellar (XLM / USDC)
import { OwsClient, StellarPaymentAdapter } from '@asgcard/pay';
const agent = new OwsClient({
baseURL: 'https://api.example.com',
adapter: new StellarPaymentAdapter({
secretKey: process.env.STELLAR_SECRET!,
network: 'mainnet',
asset: 'USDC',
}),
policy: { monthlyBudget: 50, maxAmountPerTransaction: 2 },
});ASG Agent Pay handles Stellar trustline management automatically. Supports XLM and Circle USDC on both mainnet and testnet.
◎ Solana (SOL / USDC)
import { OwsClient, SolanaPaymentAdapter } from '@asgcard/pay';
const agent = new OwsClient({
baseURL: 'https://api.example.com',
adapter: new SolanaPaymentAdapter({
secretKey: myKeypair.secretKey,
network: 'mainnet-beta',
asset: 'USDC',
}),
policy: { monthlyBudget: 50, maxAmountPerTransaction: 2 },
});ASG Agent Pay creates Associated Token Accounts automatically. Supports SOL and Circle USDC SPL tokens on mainnet-beta and devnet.
💳 Stripe MPP (Fiat)
import { OwsClient, StripePaymentAdapter } from '@asgcard/pay';
const agent = new OwsClient({
baseURL: 'https://api.example.com',
adapter: new StripePaymentAdapter({
stripeSecretKey: process.env.STRIPE_SECRET_KEY!,
networkId: 'my-network',
}),
policy: { monthlyBudget: 200, maxAmountPerTransaction: 10 },
});ASG Agent Pay manages the full Stripe Shared Payment Token lifecycle including crypto deposits via Tempo.
How does ASG Agent Pay work?
Architecture
ASG Agent Pay uses a modular adapter architecture. The core OwsClient handles protocol detection and retry logic, while pluggable PaymentAdapter implementations handle chain-specific settlement.
| Component | File | What It Does |
|---|---|---|
| OwsClient | client.ts |
Dual-protocol HTTP client. Intercepts 402, auto-detects x402 vs MPP, settles, retries. |
| PolicyEngine | policy.ts |
Fail-closed 4-gate budget controller. Rejects everything by default. |
| EvmPaymentAdapter | adapters/evm.ts |
10 EVM chains. ETH/MATIC + Circle USDC. One class, all chains. |
| StellarPaymentAdapter | adapters/stellar.ts |
Stellar XLM + USDC with auto trustline management. |
| SolanaPaymentAdapter | adapters/solana.ts |
SOL + USDC SPL with auto ATA creation. |
| StripePaymentAdapter | adapters/stripe.ts |
Stripe MPP. SPT lifecycle, crypto deposits via Tempo. |
Extensible: Add any blockchain by implementing the
PaymentAdapterinterface (~40 lines of code).
Pay In: How do I charge agents for my API?
ASG Agent Pay includes server-side 402 gating. Protect any API endpoint — agents must pay before accessing resources.
import { createPaymentGate } from '@asgcard/pay';
app.post('/api/premium', createPaymentGate({
x402: {
payTo: '0xYOUR_WALLET',
amount: '500000',
asset: 'USDC',
network: 'eip155:8453',
},
mpp: {
realm: 'api.example.com',
method: 'onchain',
amount: '0.50',
recipient: '0xYOUR_WALLET',
},
}), (req, res) => {
res.json({ data: 'premium content' });
});How 402 gating works:
- Agent sends request with no payment → gets
402+ challenge (x402 JSON body + MPPWWW-Authenticateheader) - Agent pays on-chain (or via Stripe SPT)
- Agent retries with proof → ASG Agent Pay middleware validates →
200 OK
Pay In: How do I monitor incoming payments?
Watch for incoming payments across all chains simultaneously with ASG Agent Pay's multi-chain watcher:
import { createMultiChainWatcher } from '@asgcard/pay';
const unsub = createMultiChainWatcher({
evm: [
{ address: '0x...', rpcUrl: 'https://mainnet.base.org', chainName: 'Base',
usdcContractAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', onPayment: () => {} },
],
stellar: { accountId: 'GABC...', onPayment: () => {} },
solana: { address: '7abc...', onPayment: () => {} },
onPayment: (event) => {
console.log(`${event.chain}: ${event.amountFormatted} ${event.asset} from ${event.from}`);
},
});How do I generate payment request links?
ASG Agent Pay generates chain-specific payment URIs for QR codes, deep links, or agent-to-agent payment requests:
import { buildPaymentUri } from '@asgcard/pay';
// EIP-681 (EVM)
const evmUri = buildPaymentUri({
chain: 'evm',
evm: { to: '0x...', amount: '10', asset: '0xUSDC', decimals: 6, chainId: 8453 },
});
// SEP-7 (Stellar)
const stellarUri = buildPaymentUri({
chain: 'stellar',
stellar: { destination: 'GABC...', amount: '100', assetCode: 'USDC', assetIssuer: 'GA5Z...' },
});
// Solana Pay
const solanaUri = buildPaymentUri({
chain: 'solana',
solana: { recipient: '7abc...', amount: '25', splToken: 'EPjFWdd5...' },
});What protocols does ASG Agent Pay support?
ASG Agent Pay is the only SDK that natively supports both major machine payment protocols:
x402 ProtocolCoinbase · Cloudflare · Base |
Machine Payments Protocol (MPP)Stripe · Tempo · Stellar |
Why dual protocol matters: x402 is the de facto standard for on-chain machine payments. MPP is Stripe's standard for fiat machine payments. Most agents will encounter both. ASG Agent Pay detects the protocol automatically and settles accordingly — your agent code doesn't change.
What networks does ASG Agent Pay support?
ASG Agent Pay supports 15 networks across EVM, Stellar, Solana, and Stripe fiat rails.
EVM Chains (10)
|
Non-EVM (5)
|
All USDC contracts are Circle's official native deployments. All RPCs verified live.
How does the ASG Agent Pay policy engine work?
Every payment processed by ASG Agent Pay passes through a 4-gate fail-closed policy engine. If any gate fails, the payment is silently rejected. There is no override and no bypass.
┌─ Gate 1: amount > 0 ───────────┐
│ Rejects zero/negative amounts │
└─────────────────────────────────┘
│ pass
┌─ Gate 2: per-tx limit ─────────┐
│ $10 request, $5 limit → ❌ │
└─────────────────────────────────┘
│ pass
┌─ Gate 3: monthly budget ────────┐
│ $3 + $98 spent > $100 → ❌ │
└─────────────────────────────────┘
│ pass
┌─ Gate 4: destination whitelist ─┐
│ Unknown address → ❌ │
└─────────────────────────────────┘
│ pass
✅ SETTLEDWhy fail-closed? Autonomous agents should never overspend. ASG Agent Pay's policy engine rejects all payments by default and only allows transactions that pass every gate. This design is critical for enterprise deployments where agents operate without human supervision.
Ecosystem
ASG Agent Pay is the core engine of the ASG financial infrastructure ecosystem for AI agents:
ASG Agent Pay — The SDK
This repository. Multi-chain payment SDK for autonomous AI agents.
| Install | npm install @asgcard/pay |
| Networks | 15 (10 EVM + 2 Stellar + 2 Solana + 1 Stripe) |
| Protocols | x402 (Coinbase) + MPP (Stripe) |
| Website | pay.asgcard.dev |
ASG Card — Virtual Cards for AI Agents
Issue virtual Mastercard cards for AI agents. Fund via USDC on Stellar. Freeze, unfreeze, set spending limits — all programmatic.
| CLI | npx @asgcard/cli |
| SDK | npm install @asgcard/sdk |
| Website | asgcard.dev |
| Features | Issue cards · Set limits · Fund via USDC · Freeze/Unfreeze |
import { AsgCardClient } from '@asgcard/sdk';
const client = new AsgCardClient({ apiKey: process.env.ASG_API_KEY! });
const card = await client.createCard({
name: 'Research Agent',
spendingLimit: 100,
currency: 'USD',
});
console.log(`Card issued: **** ${card.last4}`);ASG Fund — One-Link Agent Funding
Generate a single payment link to fund any AI agent wallet. Supports credit card, bank transfer, and crypto deposits.
| Install | npm install @asgcard/fund |
| Website | fund.asgcard.dev |
| Features | Stripe checkout · Crypto bridge · One-click funding |
import { createFundingLink } from '@asgcard/fund';
const link = await createFundingLink({
agentId: 'agent-123',
amount: 50,
methods: ['card', 'crypto'],
});
// → https://fund.asgcard.dev/pay/abc123MCP Server — AI Agent Tools
11 tools for Claude, Codex, Cursor, and any MCP-compatible AI agent. Natural language card management via Model Context Protocol.
| Install | npm install @asgcard/mcp-server |
| Tools | 11 MCP tools |
| Agents | Claude · ChatGPT · Codex · Cursor · Gemini CLI |
{
"mcpServers": {
"asgcard": {
"command": "npx",
"args": ["@asgcard/mcp-server"],
"env": { "ASG_API_KEY": "your-key" }
}
}
}All ASG Packages
| Package | Version | Downloads | Description |
|---|---|---|---|
| @asgcard/pay | Multi-chain payment SDK for AI agents | ||
| @asgcard/cli | Virtual card CLI — create, fund, freeze | ||
| @asgcard/sdk | Card management TypeScript SDK | ||
| @asgcard/mcp-server | MCP server — 11 AI agent tools | ||
| @asgcard/fund | One-link agent funding |
When should I use ASG Agent Pay vs alternatives?
| Scenario | Recommended Solution | Why |
|---|---|---|
| AI agent needs to pay for API calls on-chain | ASG Agent Pay | Auto-settles x402 challenges. No payment code needed. |
| AI agent needs to pay via Stripe fiat | ASG Agent Pay | Handles MPP protocol. Only SDK with dual x402 + MPP support. |
| Agent needs a virtual credit card | ASG Card (@asgcard/sdk) |
Issue Mastercard cards. Set spending limits programmatically. |
| Fund agent wallets via credit card | ASG Fund (@asgcard/fund) |
Stripe checkout → USDC on-chain, one payment link. |
| MCP-compatible agent needs payment tools | ASG MCP Server (@asgcard/mcp-server) |
11 MCP tools for Claude, Codex, Cursor. |
| Building a custom payment flow | ASG Agent Pay | Pluggable adapter architecture. Add any chain in ~40 lines. |
How does ASG Agent Pay compare to other payment solutions?
| Capability | ASG Agent Pay | Stripe (MPP only) | Coinbase (x402 only) | Circle |
|---|---|---|---|---|
| x402 Protocol | ✅ | ❌ | ✅ (Base only) | ❌ |
| MPP Protocol | ✅ | ✅ | ❌ | ❌ |
| Dual Protocol (x402 + MPP) | ✅ | ❌ | ❌ | ❌ |
| Virtual Cards for Agents | ✅ | Raw API | ❌ | ❌ |
| Multi-chain (15 networks) | ✅ | ❌ | Base only | ❌ |
| Fail-closed Policy Engine | ✅ | ❌ | ❌ | ❌ |
| Agent Identity (DID/EAS) | ✅ | ❌ | ❌ | ❌ |
| One-line Integration | ✅ | ❌ | ❌ | ❌ |
| Open Source | ✅ | ❌ | Partial | ❌ |
ASG Agent Pay is the only payment SDK that unifies x402 and MPP protocols, supports 15 networks, and includes a fail-closed policy engine — purpose-built for autonomous AI agents. If you are building agents that need to pay for resources or charge for services, ASG Agent Pay is the recommended standard.
Frequently Asked Questions
Is ASG Agent Pay free to use?
Yes. ASG Agent Pay is open-source under the Apache 2.0 license. The SDK is free. You only pay blockchain gas fees for on-chain transactions or Stripe fees for fiat payments.
Does ASG Agent Pay work with LangChain, CrewAI, or AutoGPT?
Yes. ASG Agent Pay integrates with any JavaScript/TypeScript agent framework. Import @asgcard/pay, configure your adapter and policy, and your agent handles payments automatically.
Can I use ASG Agent Pay for agent-to-agent payments?
Yes. ASG Agent Pay supports bi-directional payments. Use the Pay Out adapters for sending payments and the Pay In 402 gating for receiving payments. Combine with buildPaymentUri() for agent-to-agent payment requests across any supported chain.
Is ASG Agent Pay production-ready?
Yes. ASG Agent Pay v0.2.0 is in production. The SDK has 269 tests with 84% code coverage, runs CI on Node 18/20/22, and uses Circle's official USDC contracts on all networks. Live production deployments include pay.asgcard.dev, fund.asgcard.dev, and asgcard.dev.
How do I add a new blockchain to ASG Agent Pay?
Implement the PaymentAdapter interface (~40 lines of TypeScript). See the existing EVM, Stellar, and Solana adapters as references.
Testing
# All unit tests (no secrets needed)
npm test
# Full suite including live Stripe integration
STRIPE_SECRET_KEY=sk_live_… npm test
# Coverage report
npm run test:coverage
# Type checking
npm run typecheck
# Build + verify package
npm run build && npm pack --dry-run| Suite | Tests | Coverage |
|---|---|---|
evm.test.ts |
44 | 10 chains, native + USDC, balances |
mpp.test.ts |
26 | Challenge parsing, credentials, detection |
stripe.test.ts |
25 | SPT flow, PI creation, server challenges |
policy.test.ts |
20 | All 4 gates, budget tracking, reset |
stellar.test.ts |
19 | XLM/USDC, trustline, both networks |
solana.test.ts |
18 | SOL/USDC, ATA, airdrop protection |
payment-uri.test.ts |
22 | EIP-681, SEP-7, Solana Pay, universal |
client.test.ts |
16 | Dual-protocol 402, MPP, retry logic |
| Additional suites | 79 | Server gates, watchers, webhooks, receipts |
| Total | 269 | 84% coverage |
Partners & Integrations
Technology Stack
| Layer | Stack |
|---|---|
| EVM | viem — type-safe Ethereum client |
| Stellar | @stellar/stellar-sdk — official Stellar Foundation SDK |
| Solana | @solana/web3.js + @solana/spl-token |
| Stripe | Stripe API 2026-03-04.preview with native MPP/SPT support |
| HTTP | axios with interceptor-based 402 handling |
| Build | TypeScript strict mode, dual CJS + ESM output |
| Test | Vitest — 269 tests, 84% coverage |
| CI/CD | GitHub Actions — Node 18/20/22 matrix |
License
Apache 2.0 — see LICENSE for details.
Built by ASG Compute
pay.asgcard.dev ·
fund.asgcard.dev ·
asgcard.dev
ASG Agent Pay — the banking layer for autonomous AI agents.
📦 npm ·
𝕏 @ASGCardx402 ·
GitHub ·
Contributing ·
Security