Agent SDK
Overview
@kryptwarden/sdk: pay x402 APIs from a KryptWarden wallet, within policy.
Package: @kryptwarden/sdk on npm
The SDK is a wrapper around fetch. When a server answers 402 Payment Required, it pays from the agent's KryptWarden wallet, within the policy the owner set, and retries the request.
npm install @kryptwarden/sdk- Node.js 20 or newer, ESM only.
- Published with npm provenance from GitHub Actions.
- MIT licence.
Minimal example
import { createKryptWarden } from "@kryptwarden/sdk";
const kw = createKryptWarden({
walletAddress: process.env.KW_WALLET_ADDRESS!,
agentSecretKey: process.env.KW_AGENT_SECRET_KEY!,
network: "stellar:testnet",
});
const res = await kw.fetch("https://demo-apis.kryptwarden.xyz/paid/search?q=soroban");Configuration
Prop
Type
Environment variables
The SDK reads only one variable itself: FACILITATOR_URL, as the relayer when relayerUrl isn't set. The examples in these docs use these names by convention:
| Variable | Value |
|---|---|
KW_WALLET_ADDRESS | The wallet's C… contract ID |
KW_AGENT_SECRET_KEY | The agent secret, written by keygen |
KW_AGENT_PUBLIC_KEY | The agent's G… key, written by keygen |
Next
- API reference
- Errors
- CLI
- Pay with the SDK: patterns for real agents.