Use with agents

Give your AI agent a funded account. It pays for any service on the SPX network — automatically, instantly, with no transaction per call.

Install

npm install @spx/sdk

Set up your agent

import { SpxClient } from "@spx/sdk/agent";

const spx = new SpxClient({
  agentKey: myKeypair.secretKey,      // agent's payment key
  fundingSource: "YourFundingPDA",    // where the money comes from
});

The agent key can authorize payments but can never withdraw funds. You stay in control.

Pay for a service

// Every API call — instant, free, no blockchain transaction
const { header } = spx.pay(serviceKey, price);

const res = await fetch("https://api.example.com/data", {
  headers: { "X-Payment": header },
});

Each .pay() call takes under 1ms. No on-chain transaction. No RPC call. The service verifies the payment locally and responds immediately — your agent doesn't wait.

Pay for many services

Your agent can pay any number of services from the same funding source. No per-vendor setup.

for (const svc of services) {
  const { header } = spx.pay(svc.key, svc.price);
  const res = await fetch(svc.url, {
    headers: { "X-Payment": header },
  });
}
// 1,000 services paid. $0 in transaction fees.

How your agent stays safe

  • Hard spending limit — the funding source has a fixed balance. Your agent literally cannot spend more than what's deposited.
  • Payment key, not a wallet — the agent can authorize payments but cannot withdraw or transfer funds. Only you (the owner) can withdraw.
  • Instant freeze — you can freeze the funding source at any time. All payments stop immediately.
  • Key rotation — if the agent key is compromised, rotate it. Old authorizations become invalid instantly.

What happens behind the scenes

  1. Your agent creates a small cryptographic authorization (110 bytes) with the running total owed to that service
  2. The service verifies the authorization locally — Ed25519 signature check, microseconds
  3. The service responds immediately
  4. The service stores the latest authorization and collects everything later in one transaction

The service doesn't need to be online when it collects. Your agent doesn't need to be online when the service collects. They operate independently.

Prerequisites

Before your agent can pay, you need to:

  1. Create a funding source on-chain with a spending limit
  2. Deposit tokens (USDC) into it
  3. Assign your agent's public key — this authorizes it to make payments

Next steps