AI agent payments on Solana: a practical architecture

Solana is a reasonable home for machine payments: sub-cent fees, sub-second confirmation, and an account model that lets a program hold the money while a separate key merely asks for it. This is how to arrange those pieces for an agent that runs unattended.

Solana vaults9 min readBy the Patram team

Most agent payment designs start by giving the agent a private key. It is one line of code and it creates a single point of failure that no amount of prompt engineering can fix: whoever reads that key owns everything the agent owns.

The three accounts

A safer arrangement splits authority, custody and fees into three distinct accounts. The agent holds only the first, which is designed to be worthless on its own.

  • Agent key — an ed25519 keypair that signs requests. It never holds a balance. A leaked agent key can request transfers inside the policy and nothing outside it.
  • Vault PDA — a program-derived address owned by the Anchor program. It holds the funds and, crucially, the rule: the daily limit is stored on this account.
  • Gas tank — the owner's fee payer. It pays the network fee for every agent transaction, so the agent never needs SOL and never fails for lack of it.

The PDA address is derived from the seeds ["patram", ownerWallet, agentKey], so the vault is bound to one agent and one owner. There is no registry to trust: anyone can recompute the address and read the account.

Program
Program:  DuTvz2VmSRTCPAtA9kLocWUZqEzhjBPqWAZVTzjwNKv7
Seeds:    ["patram", ownerWallet, agentKey]
State:    daily_limit (u64, lamports), lamport balance
Cluster:  devnet

The lifecycle of one payment

  1. 01The agent decides it needs to pay, and calls the SDK with a recipient and an amount in lamports.
  2. 02The SDK reads the agent record — limit, spent, kill switch — from the Patram service.
  3. 03A local pre-check compares limit minus spent with the amount. A breach becomes an approval request instead of a transfer.
  4. 04The SDK builds the program instruction, sets the gas tank as fee payer, signs with the agent key, and sends it.
  5. 05The program checks the signer, the vault balance and the daily limit, then moves the lamports.
  6. 06The SDK confirms at confirmed commitment and writes a ledger row against the agent.

Who pays the fee

Fee abstraction matters more than it sounds. If the agent must hold SOL for fees, then the agent key holds value again, and the safety story collapses back to key management. Sponsoring fees from an owner-controlled tank keeps the agent key at zero balance forever.

Operationally: fund the tank once, alert when it drops below a threshold, and treat an empty tank as a first-class incident because it fails approved transfers.

Why Solana rather than an L2 or a card

  • Cost: a transfer costs a fraction of a cent, so 10,000 small agent payments remain economically viable.
  • Finality: confirmation in about a second, which is fast enough for a synchronous tool call.
  • Programmability: the policy runs inside the same atomic instruction as the transfer, so there is no window where the check and the spend disagree.
  • Interoperability: the same account can settle x402 invoices, pay APIs and receive owner top-ups.

Reconciliation

Two books must agree: the platform ledger, which records what the agent attempted and confirmed, and your own database, which records why. Join them on the transaction signature, never on amount — identical amounts are routine.

Reconcile by signature
const rows = await db.invoice.findMany({ where: { signature: null } });

for (const invoice of rows) {
  const entry = await ledger.findBySignature(invoice.signatureCandidate);
  if (entry?.status === "confirmed") {
    await db.invoice.update({
      where: { id: invoice.id },
      data: { signature: entry.signature, paidAt: entry.confirmedAt },
    });
  }
}

What the vault does not protect

  • The destination. If an allowlist is not configured, a persuaded agent can pay a hostile address inside its budget. Treat the allowlist as the primary control, not the cap.
  • The owner's wallet. Approvals are signed by you; a phished owner signature is outside any program's threat model.
  • Your service credentials. An API key that can create agents can create a permissive one. Scope it and rotate it.