JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1032
  • Score
    100M100P100Q103906F
  • License MIT

SDK for ASG Card — virtual MasterCard cards for AI agents, paid via x402 on Stellar

Package Exports

  • @asgcard/sdk
  • @asgcard/sdk/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@asgcard/sdk) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@asgcard/sdk

TypeScript SDK for ASG Card — instant virtual MasterCard cards for AI agents, paid via x402 on Stellar.

Install

npm install @asgcard/sdk

Quick Start

import { ASGCardClient } from '@asgcard/sdk';

const client = new ASGCardClient({
  privateKey: 'S...', // Stellar secret key
});

// Create a $10 virtual card
const result = await client.createCard({
  amount: 10,
  nameOnCard: 'AI AGENT',
  email: 'agent@example.com',
});

console.log(result.card.cardId);          // card_xxxx
console.log(result.detailsEnvelope);      // { cardNumber, cvv, expiry, ... }
console.log(result.payment.txHash);       // Stellar tx hash

How It Works

  1. SDK calls POST /cards/create/tier/100
  2. API returns 402 with x402 payment challenge
  3. SDK builds a Soroban USDC transfer, signs it, and retries with X-PAYMENT header
  4. API verifies + settles on Stellar mainnet → returns 201 with card details

API

new ASGCardClient(config)

Option Type Default Description
privateKey string Stellar secret key (S...)
walletAdapter WalletAdapter External wallet (browser extension)
baseUrl string https://api.asgcard.dev API URL
rpcUrl string https://mainnet.sorobanrpc.com Soroban RPC
timeout number 60000 Request timeout (ms)

client.createCard(params)

const card = await client.createCard({
  amount: 50,            // Any amount $5–$5,000
  nameOnCard: 'MY AGENT',
  email: 'agent@example.com',
});

client.fundCard(params)

const funded = await client.fundCard({
  amount: 25,
  cardId: 'card_xxxx',
});

client.getPricing()

const pricing = await client.getPricing();
// { cardFee: 10, topUpPercent: 3.5, minAmount: 5, maxAmount: 5000 }

client.health()

const health = await client.health();
// { status: 'ok', version: '0.3.1' }

client.listCards()

const { cards } = await client.listCards();
// cards: [{ cardId, nameOnCard, lastFour, balance, status, createdAt }]

client.getTransactions(cardId, page?, limit?)

const result = await client.getTransactions('card_xxxx');
// { cardId, transactions: [{ id, type, amount, status, merchantName, createdAt }], pagination }

client.getBalance(cardId)

const result = await client.getBalance('card_xxxx');
// { cardId, balance: 25.00, currency: 'USD', status: 'active', source: '4payments' }

Low-Level Utilities

For custom integrations:

import {
  parseChallenge,
  buildPaymentTransaction,
  buildPaymentPayload,
  handleX402Payment,
} from '@asgcard/sdk';

Requirements

  • Node.js 18+
  • Stellar account with USDC balance
  • USDC asset: CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75 (Soroban SAC)

License

MIT