Package Exports
- @asgcard/pay
Readme
๐ OWS Agent Pay
Autonomous Payment SDK for AI Agents
OWS-compliant โข x402 Protocol โข Multi-chain โข Policy-gated
The AI agent simply calls performTask() โ the SDK handles payment, policy validation, on-chain settlement, and proof generation transparently.
Documentation โข โถ Live Demo โข Architecture โข Live Products โข OWS Compliance
๐ฎ Try the interactive demo โ โ no install, no wallet, no ETH needed. Watch the full x402 flow in your browser.
๐ View the full ecosystem demo โ โ Fund โ Card โ Pay: the complete autonomous agent financial stack.
๐ก What This Solves
AI agents are rapidly becoming autonomous economic actors, but they have no native way to pay for services programmatically. OWS Agent Pay bridges this gap:
AI Agent calls API โ Server returns HTTP 402 โ SDK auto-pays โ Agent gets resultZero payment code required from the agent developer. The SDK intercepts, validates, settles, and retries โ all transparently.
โ ๏ธ This is not a hackathon prototype. We extracted the core x402 payment logic from our live production stack (10K+ monthly NPM downloads) into a clean, OWS-compliant SDK.
โก Quick Start
Option 1: Browser Demo (Zero Install)
โถ Open the live demo โ โ click "Run Live Demo" and watch the full x402 cycle in 30 seconds.
Option 2: CLI Demo
# Clone and install
git clone https://github.com/ASGCompute/ASGCompute-ows-agent-pay.git
cd ASGCompute-ows-agent-pay
npm install
# Run the demo (simulated mode โ no ETH needed)
npx ts-node demo.ts --simulate
# Or run with real Base Sepolia testnet (auto-funds via Coinbase faucet)
npx ts-node demo.tsOption 3: Use in Your Agent
import { OwsClient, BasePaymentAdapter } from 'ows-agent-pay';
const adapter = new BasePaymentAdapter({
privateKey: process.env.AGENT_PRIVATE_KEY as `0x${string}`,
network: 'mainnet',
});
const agent = new OwsClient({
baseURL: 'https://inference-api.example.com',
policy: {
monthlyBudget: 100,
maxAmountPerTransaction: 5,
allowedDestinations: ['0x...'],
},
adapter, // Swap to StellarPaymentAdapter for Stellar
});
// Agent code โ no payment logic needed!
const result = await agent.performTask('/v1/chat', {
model: 'gpt-4',
messages: [{ role: 'user', content: 'Summarize this document' }],
});Expected CLI Output
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OWS Agent Pay โ Base/EVM Autonomous Demo โ
โ Built by ASG Pay โข https://asgcard.dev โ
โ x402 Protocol โข Base (Coinbase L2) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
[Server] Mock API listening on http://localhost:4020
[Agent] Wallet: 0xAb5801a7D398991B8a7cF7706226...
[Agent] Chain: Base Sepolia (eip155:84532)
[Agent] ๐ง Requesting ETH from Base Sepolia faucetโฆ
[Agent] โ
Wallet funded from Coinbase faucet
[Agent] ๐ฐ Balance: 0.1 ETH
[Agent] ๐ง Sending inference requestโฆ
[OWS Client] โก Received 402 Payment Required challenge
[OWS Client] ๐ฐ Requested payment: $0.50
[OWS Client] โ๏ธ Settlement chain: Base (eip155:84532)
[OWS Client] โ
Policy check PASSED โ settling on-chainโฆ
[Base] ๐ Building payment โ 0xDead71โฆ8B3c4F (0.0005 ETH, Base Sepolia)
[Base] ๐ก Submitting transactionโฆ
[Base] โ
Confirmed โ hash: 0x9e8f7a6b5c4d3e2fโฆ
[OWS Client] ๐ Constructing X-PAYMENT token and retryingโฆ
[AI Agent] โ
Task completed: The AI model computed the answer...
โโ ๐ Demo complete โโโโโโโโโโโโโโโโโโโโโโโโโโโ๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโ
โ AI Agent โ
โ performTask() โ
โโโโโโโโโโฌโโโโโโโโโโ
โ HTTP POST
โโโโโโโโโโผโโโโโโโโโโ
โ OwsClient โ
โ (Axios + 402 โ
โ interceptor) โ
โโโฌโโโโโโโโโโโโโโโฌโโโ
โ โ
โโโโโโโโโโโโโโโโผโโโ โโโโโโโโโผโโโโโโโโโโโโ
โ PolicyEngine โ โ PaymentAdapter โ
โ โโโโโโโโโโโโโโ โ โ (interface) โ
โ โ Budget โ โ โ โ
โ โ Per-tx max โ โ โ โโโโโโโโโโโโโโโโ โ
โ โ Allowlist โ โ โ โ Base (viem) โ โ
โ โโโโโโโโโโโโโโ โ โ โโโโโโโโโโโโโโโโค โ
โโโโโโโโโโโโโโโโโโโ โ โ Stellar โ โ
โ โโโโโโโโโโโโโโโโค โ
โ โ (Arbitrumโฆ) โ โ
โ โโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโ| Component | File | Purpose |
|---|---|---|
| OwsClient | client.ts |
Chain-agnostic Axios wrapper with 402 interceptor |
| PolicyEngine | policy.ts |
Fail-closed budget, per-tx limits, destination allowlist |
| BasePaymentAdapter | adapters/base.ts |
On-chain settlement via Base (Coinbase L2) using viem |
| StellarPaymentAdapter | adapters/stellar.ts |
On-chain settlement via Stellar network |
| PaymentAdapter | adapters/types.ts |
Generic interface โ plug in any chain (~40 lines) |
๐ OWS Spec Compliance
| OWS Section | Requirement | Implementation |
|---|---|---|
| ยง03 Intercept | Detect 402 Payment Required |
Axios response interceptor (client.ts:44) |
| ยง04 Evaluate | Validate x402Version + accepts[] |
Envelope parser + PolicyEngine (policy.ts) |
| ยง05 Settle | Execute on-chain payment | BasePaymentAdapter / StellarPaymentAdapter |
| ยง06 Prove | Attach X-PAYMENT header |
Base64-encoded proof with tx hash + CAIP-2 chain ID |
| ยง07 Retry | Resubmit original request | Axios re-request with proof header |
| ยง08 Chains | CAIP-2 chain identifiers | eip155:8453 (Base), eip155:84532 (Sepolia), stellar:testnet |
๐ Policy Engine (Fail-Closed)
Every payment must pass all three checks before execution:
const policy: BudgetPolicy = {
monthlyBudget: 50.0, // USD cap per calendar month
maxAmountPerTransaction: 5.0, // USD cap per single payment
allowedDestinations: [ // Whitelist of recipient addresses
'0xDead7101a13B2B6e2A4497706226bc3c4F',
],
};โ Over budget โ REJECTED
โ Over per-tx limit โ REJECTED
โ Unknown destination โ REJECTED
โ
All checks pass โ SETTLED
โ๏ธ Supported Chains
| Chain | Adapter | CAIP-2 | Status |
|---|---|---|---|
| Base (Coinbase L2) | BasePaymentAdapter |
eip155:8453 |
โ Live |
| Base Sepolia | BasePaymentAdapter |
eip155:84532 |
โ Testnet |
| Stellar | StellarPaymentAdapter |
stellar:pubnet |
โ Live |
| Arbitrum | EvmPaymentAdapter |
eip155:42161 |
๐ Next |
| Solana | SolanaPaymentAdapter |
solana:mainnet |
๐ Planned |
| Sui | SuiPaymentAdapter |
sui:mainnet |
๐ Planned |
๐ก Any chain can be added by implementing the
PaymentAdapterinterface (~40 lines).
๐ Live Production Products
This is not a hackathon prototype. Every product below is deployed and serving real traffic right now.
๐ Try them yourself
๐ณ ASG PayUniversal Payment Gateway The AI agent payment infrastructure. Accept fiat and crypto across 60+ chains. npm install @asgcard/pay |
๐ฐ ASG FundAgent Wallet Funding Top up any AI agent's wallet with USDC on Stellar โ via card, bank, or stablecoin. npm install @asgcard/fund |
๐ ASG CardVirtual Cards for AI Agents Issue virtual debit cards on demand. Pay via x402 or Stripe Machine Payments. npx @asgcard/cli |
๐ฆ NPM Packages
๐ฎ Interactive Demos
| Demo | URL | What You'll See |
|---|---|---|
| Browser Demo | โถ index.html | Full x402 cycle: 402 โ Policy โ Settlement โ Proof โ Result. Zero install. |
| Ecosystem Demo | โถ ecosystem.html | 3 interactive tabs: Fund Agent โ Issue Card โ x402 Pay โ each with live terminal. |
| Fund Agent | โถ fund.asgcard.dev | Real agent wallet ($14.37 USDC + XLM on Stellar mainnet). |
| Issue Card | โถ asgcard.dev | Virtual debit card issuance for AI agents via x402 + Stripe. |
๐ Hackathon Track Alignment
| Track | Alignment |
|---|---|
| ๐ฐ Payments | โญ Core โ x402 autonomous settlement on Base |
| ๐ค AI Agents | โญ Core โ transparent payment layer for agents |
| ๐ Agent Spend Governance | โญ Core โ PolicyEngine (fail-closed budget control) |
| ๐ Interoperability | Multi-chain adapters via CAIP-2 |
| ๐๏ธ Infrastructure | Production SDK + ASG Pay ecosystem |
๐ค Sponsor & Partner Alignment
|
Primary settlement Native x402 chain |
USDC settlement EVM + Stellar |
Production adapter Mainnet USDC |
EVM adapter Roadmap |
Fiat settlement fund.asgcard.dev |
Cross-chain Aggregator |
Bridging Partner |
๐ฃ๏ธ Roadmap
- OWS-compliant 402 interceptor with policy engine
- Base adapter (viem, Coinbase L2 โ native x402 chain)
- Stellar adapter (production-proven via ASG Pay)
- Multi-chain adapter interface (CAIP-2)
- Interactive browser demo (GitHub Pages)
- Full ecosystem demo (Fund โ Card โ Pay lifecycle)
- Arbitrum / OP Stack adapters
- Solana adapter (via @solana/web3.js)
- Li.Fi integration (cross-chain settlement aggregator)
- MCP tool server (A2A protocol bridge)
- USDC (ERC-20) transfer support on Base
๐ Key Metrics
| Metric | Value |
|---|---|
| NPM Downloads | 10K+ monthly (@asgcard) |
| SDK Size | ~529 lines TypeScript |
| Dependencies | 3 (viem, axios, @stellar/stellar-sdk) |
| Chains Live | 2 (Base + Stellar) |
| Products Live | 3 (pay, fund, card) โ all in production |
| OWS Compliance | 6/6 specification sections |
| License | MIT |
๐ License
MIT โ see LICENSE for details.
Built with โค๏ธ by ASG Compute
pay.asgcard.dev โข fund.asgcard.dev โข asgcard.dev
Autonomous payments for autonomous agents.