Agent SDK
One ES module, https://www.allowanceengine.com/sdk/agent.mjs, built on @solana/web3.js. Node 18 or later.
npm i @solana/web3.js
curl -O https://www.allowanceengine.com/sdk/agent.mjsimport { createAgent, usdc } from "./agent.mjs";
const agent = createAgent({
owner: "YourWalletAddress",
arm: 0,
secretKey: process.env.AGENT_KEY, // the session key (base58 or JSON array), never the wallet's
facilitator: "https://www.allowanceengine.com/api/x402",
maxPerCall: usdc(0.25), // optional local guard on top of the onchain budget
});
await agent.status(); // { open, balance, budgetLeft, dailyCap, spentToday, callsToday, allow, active, ... }
await agent.paidFetch(url, init); // fetch that pays a 402 by itself
await agent.pay("PayeeAddress", usdc(1)); // gasless payment to an allow-listed address
await agent.payDirect("PayeeAddress", usdc(1)); // sent by the key itself, needs a little SOL
await agent.quote(usdc(1)); // relay fee, fee account, fee payer, blockhash
await agent.signPayment({ payTo, amount }); // the raw signed transaction, base64Amounts are bigints in USDC units (6 decimals). usdc(1.5) returns 1500000n.