Solana Smart Wallet Payments with x402

web3luka
Mar 2, 2026 · 3 min read
Solana Smart Wallet Payments with x402

The x402 protocol enables HTTP-native micropayments - an API returns 402 Payment Required, the client signs and retries, and the server settles on-chain. Until now, most x402 integrations assumed a standard keypair wallet. With @relai-fi/x402@0.5.19, any Solana smart wallet works out of the box.

What Are Solana Smart Wallets?

A smart wallet is an account controlled by a program rather than a private key. Instead of a single keypair signing every transaction, the signing authority can be:

  • A multisig threshold — e.g. 2-of-3 members approve every transaction (Squads Protocol)
  • An MPC cluster — the private key is never held in one place (Crossmint, Privy, Turnkey)
  • A session key with scoped permissions — time-limited or amount-limited signing (SWIG)
  • A program-controlled PDA — on-chain AI agent treasuries, DAO spending wallets
These wallets use off-curve public keys — addresses derived from a program, not a private key. They are increasingly common in production, especially for AI agent infrastructure and institutional setups.

How It Works with RelAI

The SolanaWallet interface in @relai-fi/x402 requires only two things:

interface SolanaWallet {
  publicKey: { toString(): string } | null;
  signTransaction: ((tx: unknown) => Promise) | null;
}

This is the same interface as @solana/wallet-adapter. Every major smart wallet provider already implements it. The SDK calls wallet.signTransaction(transaction) and delegates all signing logic to the wallet itself — whether that means a CPI to the Squads program, an MPC threshold signature, or a SWIG session key verification.

The one technical detail: Associated Token Accounts for off-curve PDAs must be resolved with allowOffCurve: true. The SDK handles this automatically since 0.5.19 — no client code changes required.

Usage

Pass your smart wallet as wallets.solana — identical to a regular Phantom or Backpack wallet:

import { createX402Client } from '@relai-fi/x402/client';

// Works with Squads, Crossmint, SWIG, Privy, Turnkey, or any wallet-adapter compatible wallet
const client = createX402Client({
wallets: { solana: yourSmartWallet },
});

const response = await client.fetch('https://api.example.com/protected');
const data = await response.json();

The React hook works identically:

import { useRelaiPayment } from '@relai-fi/x402/react';

const { fetch, isLoading, transactionUrl } = useRelaiPayment({
wallets: { solana: yourSmartWallet },
});

No adapter layer, no wrapper, no configuration flags. If the wallet implements signTransaction, it works.

Supported Providers

ProviderTypeNotes
Squads ProtocolMultisig PDAn-of-m signing via CPI — works if vault has USDC ATA
CrossmintMPC / embeddedImplements standard wallet-adapter interface
SWIGSession key delegationScoped signing with time/amount limits
Privy / TurnkeyMPC custodialServer-side signing — key never leaves MPC threshold
On-chain agentsProgram-controlled PDAAutonomous AI agent treasuries

Why This Matters for AI Agents

AI agents running on Solana increasingly use program-controlled wallets — either a PDA owned by their program or a Squads multisig for treasury management. With smart wallet support, an AI agent can pay for API access autonomously, using its own on-chain wallet, without any human in the signing loop.

Agent PDA wallet -> x402 API -> RelAI facilitator -> SPL transfer -> content returned

RelAI covers gas (SOL for transaction fees), so the agent only needs USDC in its ATA. One token, one action, no infrastructure overhead.

One Requirement

The smart wallet's USDC Associated Token Account must exist on-chain before the first payment. For a Squads vault PDA, this means creating a USDC ATA for the vault address — any standard ATA creation tool works (spl-token create-account, Squads UI, or any on-chain ATA initializer).


Update to @relai-fi/x402@0.5.19 and check the SDK documentation for the full reference.

RelAI is the gas-sponsoring facilitator for the x402 payment protocol. We cover gas fees on Solana, Ethereum, Polygon, Base, Avalanche, and SKALE so users only pay for content — in USDC.

Understand x402 before you implement

This guide uses payment primitives from the x402 standard. Read the protocol overview for a complete flow, terminology, and integration FAQ.