Owner setup
- Connect Phantom on devnet and sign in.
- Create a hosted agent wallet and copy the API key once.
- Fund the hosted agent with devnet SOL and test tokens.
- Configure recipients, limits, token mint, and publish policy on-chain.
Agent integration docs
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.
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.
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);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.
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());