Skip to main content
ConceptsMeta-tools

codespar_crypto_pay

Crypto payments. Stablecoin USD on Coinbase Commerce; crypto BRL on Bitso (BR fiat-onramp via crypto rail).

2 min read · updated

codespar_crypto_pay

Meta-tool

codespar_crypto_pay is the crypto-rail meta-tool. Use it when the buyer or recipient wants to settle in stablecoin or another crypto asset rather than fiat — typical for cross-border B2B settlement, stablecoin payouts, and Bitso's BR fiat-onramp flow.

There is no typed wrapper yet — call via session.execute().

Rails

RailCurrencyCountryProviderNotes
StablecoinUSD (USDC)INTLCoinbase CommerceDefault. Returns hosted payment URL
CryptoBRLBRBitsoBR-friendly fiat-onramp via crypto. hmac_signed auth pattern

Coinbase Commerce returns a payment page URL — share with the user, they pay any supported chain, and the webhook lands when settled. Bitso is the right pick when the operator wants to accept BRL but settle internally in crypto (or vice versa).

Direct execute

const result = await session.execute("codespar_crypto_pay", {
  amount: "0.05",
  currency: "ETH",
  method: "stablecoin",
  recipient: { wallet_address: "0xabc..." },
  metadata: { order_id: "1234" },
});

console.log(result.payment_url ?? result.destination_address, result.tool_call_id);

Args shape

FieldTypeRequiredDescription
amountstring | numberYesCrypto amounts pass as decimal strings to avoid float rounding
currencystringYesUSDC, ETH, BTC, BRL (Bitso)
methodstringNostablecoin (default), native_crypto
recipientobjectNo{ wallet_address } for outbound; omitted for inbound (returns hosted URL)
metadataobjectNoArbitrary key-value pairs

Result shape

type CryptoPayResult = {
  tool_call_id: string;
  payment_url?: string;          // Coinbase Commerce hosted URL — inbound flow
  destination_address?: string;  // for outbound payouts
  expires_at?: string;
  status: "pending";             // terminal state via paymentStatus
};

Operator setup

  • Coinbase Commerce — API key (api_key auth_type). Optional shared-secret for webhook verification.
  • Bitsohmac_signed auth_type. Operator stamps API key + API secret in /dashboard/auth-configs; runtime signs each request with HMAC-SHA256 over nonce + method + path + body.

The Coinbase Commerce catalog row currently has an auth-shape mismatch flagged in the operator runbook — verify the connect modal shows the right inputs (API key + shared secret) before stamping production credentials.

Async settlement

Crypto rails settle on-chain; latency varies by chain (seconds for most stablecoins on Polygon / Arbitrum, minutes on Bitcoin). The flow mirrors codespar_charge:

  1. codespar_crypto_pay returns the payment_url or destination_address and a tool_call_id.
  2. Buyer pays on the hosted page or sends the on-chain transfer.
  3. Provider webhook lands — backend correlates by idempotency_keyexternal_reference.
  4. session.paymentStatus(tool_call_id) returns succeeded (or expired if the buyer abandoned).

See async settlement.

See also

Edit on GitHub

Last updated on