AgentWallet

Agent integration docs

Give any AI agent a policy-enforced Solana wallet.

AgentWallet hosts the agent wallet, keeps the signing key encrypted, and exposes a small SDK/API. Your agent sends payment intents; AgentWallet settles only if the owner policy allows it.

01

Owner setup

  1. Connect Phantom on devnet and sign in.
  2. Create a hosted agent wallet and copy the API key once.
  3. Fund the hosted agent with devnet SOL and test tokens.
  4. Configure recipients, limits, token mint, and publish policy on-chain.
02

Agent runtime

The agent never receives the private key. It only receives an AgentWallet API key. Every call is checked against the policy PDA before tokens move on Solana devnet.

SDK quickstart

Use from a Node or TypeScript agent

import { AgentWallet } from "@agentwallet/sdk";

const wallet = new AgentWallet({
  baseUrl: "https://agentspend-eight.vercel.app",
  apiKey: process.env.AGENTWALLET_API_KEY!
});

const me = await wallet.getAgent();
if (!me.status.readyForPayments) {
  throw new Error("AgentWallet setup incomplete: " + me.status.missing.join(", "));
}

const payment = await wallet.pay({
  recipient: "6tNgWp8rq4UJ77q2cZ8WPeBn5eUDhcSuC5nSEXd1W8yA",
  amount: "1"
});

console.log(payment.explorerUrl);
REST API

Use from any agent framework

GET /api/agent-wallet/me
Authorization: Bearer <agent-api-key>

POST /api/agent-wallet/pay
Authorization: Bearer <agent-api-key>
Content-Type: application/json

{
  "recipient": "6tNgWp8rq4UJ77q2cZ8WPeBn5eUDhcSuC5nSEXd1W8yA",
  "amount": "1"
}

The server uses the stored program ID, policy PDA, token mint, and decimals from the hosted agent record. Override fields only when you are building an advanced integration and still expect the on-chain policy to enforce them.

x402 flow

Pay APIs without API keys

const response = await wallet.fetch("https://merchant.example/resource");

// If the merchant returns 402 + PAYMENT-REQUIRED,
// AgentWallet pays through policy and retries with PAYMENT-SIGNATURE.
console.log(await response.json());