npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lumenjoule-sdk

v1.2.0

Published

x402 agent wallet SDK for Stellar — smart accounts with pluggable signers (Ed25519, P-256 Secure Enclave) and on-chain spend policies

Readme

lumenjoule-sdk

Pay for AI inference with USDC or LumenJoule on Stellar. Handles the x402 payment protocol automatically — your agent sends a chat request, the SDK detects the 402, builds a signed payment from your smart wallet, and retries.

Install

npm install lumenjoule-sdk

Smart Wallet Client (Recommended)

Pays from a C-address smart wallet with on-chain spend policies. Works with Ed25519 agent keys (keypair) or Secp256r1 keys (Secure Enclave / software P-256).

import { SmartWalletClient } from "lumenjoule-sdk";

const client = new SmartWalletClient({
  agentSecretKey: process.env.AGENT_SECRET,  // Ed25519 S... key
  walletAddress: "CXXX...",                   // Smart wallet C-address
  network: "mainnet",
});

const response = await client.chat({
  model: "meta-llama/Llama-3.3-70B-Instruct",
  messages: [{ role: "user", content: "Hello!" }],
});

console.log(response.choices[0].message.content);
console.log("TX:", response._payment.transaction);

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | walletAddress | string | required | Smart wallet C-address | | agentSecretKey | string | - | Ed25519 secret key (S...) | | signer | AgentSigner | - | Pluggable signer (alternative to agentSecretKey) | | computeUrl | string | https://compute.lumenbro.com | Compute server URL | | network | "testnet" \| "mainnet" | "mainnet" | Stellar network | | rpcUrl | string | auto | Custom Soroban RPC URL | | preferredAsset | string | USDC SAC | Payment asset (defaults to USDC) | | policyAddress | string | - | Spend policy contract for budget queries |

Methods

client.chat(request) — OpenAI-compatible chat completion with automatic x402 payment.

client.payAndFetch(url, init?) — Generic x402 payment for any endpoint.

client.transfer(token, to, amount) — Direct token transfer (Ed25519 only, agent pays gas).

client.usdcBalance() — USDC balance of the smart wallet (7-decimal stroops).

client.balance(token?) — Token balance query (defaults to LumenJoule).

client.gasBalance() — XLM balance (for gas estimation).

Spend Policy Queries

Requires policyAddress in config. Returns values in 7-decimal stroops (divide by 1e7 for USD).

const client = new SmartWalletClient({
  agentSecretKey: process.env.AGENT_SECRET,
  walletAddress: "CXXX...",
  policyAddress: "CBRGH27ZFVFDIHYKC4K3CSLKXHQSR5CFG2PLPZ2M37NH4PYBOBTTQAEC", // $50/day
});

const budget = await client.budgetStatus();
console.log(`Limit: $${budget.dailyLimitUsdc}`);
console.log(`Spent: $${budget.spentTodayUsdc}`);
console.log(`Left:  $${budget.remainingUsdc}`);

Individual queries: client.dailyLimit(), client.spentToday(), client.remaining().

Mainnet policy tiers: | Tier | Daily Limit | Contract | |------|-------------|----------| | Starter | $50/day | CBRGH27ZFVFDIHYKC4K3CSLKXHQSR5CFG2PLPZ2M37NH4PYBOBTTQAEC | | Production | $500/day | CCRIFGLMG3PT7R3V2IFSRNDNKR2Y2DLJAI5KXYBKNJPFCL2QC4MDIZNJ | | Enterprise | $2,000/day | CCSPAXNEVBNA5QAEU2YEUTU56O5KOZM4C2O7ONQ6GFPSHEWV5OJJS5H2 |

Pluggable Signers

The SDK supports multiple signer types for smart wallet authentication.

Ed25519 (Default)

Standard Stellar keypair. Provide agentSecretKey or use Ed25519AgentSigner directly.

import { SmartWalletClient, Ed25519AgentSigner } from "lumenjoule-sdk";

const client = new SmartWalletClient({
  signer: new Ed25519AgentSigner("SXXX..."),
  walletAddress: "CXXX...",
});

Secp256r1 — Secure Enclave (macOS)

Hardware-bound P-256 keys via keypo-signer. Keys never leave the Secure Enclave.

import { SmartWalletClient, KeypoSigner } from "lumenjoule-sdk";

const signer = new KeypoSigner({
  keyLabel: "my-agent-key",
  publicKey: Buffer.from("BASE64_PUBLIC_KEY", "base64"),
});

const client = new SmartWalletClient({
  signer,
  walletAddress: "CXXX...",
});

Secp256r1 — Software P-256 (Cross-Platform)

Software ECDSA P-256 keys for development/testing on any platform. Keys stored encrypted on disk.

import { SmartWalletClient, SoftP256Signer } from "lumenjoule-sdk";

// Generate a new key (first time)
const signer = await SoftP256Signer.generate("my-password");

// Load existing key
const signer = await SoftP256Signer.load("my-password");

const client = new SmartWalletClient({
  signer,
  walletAddress: "CXXX...",
});

LumenJoule Client (Legacy)

Pays from a G-address keypair using LumenJoule tokens directly.

import { LumenJouleClient } from "lumenjoule-sdk";

const client = new LumenJouleClient({
  secretKey: "SXXXX...",
  network: "mainnet",
});

const response = await client.chat({
  model: "meta-llama/Llama-3.3-70B-Instruct",
  messages: [{ role: "user", content: "Hello!" }],
});

x402 Protocol Helpers

Lower-level helpers for custom x402 integrations.

import { parsePaymentRequirements, encodePaymentHeaders, performX402Dance } from "lumenjoule-sdk";

// Parse 402 response headers
const requirements = await parsePaymentRequirements(response);

// Encode payment for retry
const headers = encodePaymentHeaders(payloadJson);

// Full dance: request → 402 → build payment → retry
const paidResponse = await performX402Dance(url, init, buildPaymentFn);

Links