x402 Stellar
Core library with types, schemas, and facilitator client for building custom integrations.
Installation
npm install x402-stellarUsage
Types and Schemas
import {
PaymentPayloadSchema,
PaymentRequirementsSchema,
type PaymentPayload,
type PaymentRequirements,
} from "x402-stellar";
// Validate a payment payload
const result = PaymentPayloadSchema.safeParse(payload);
if (result.success) {
const validPayload: PaymentPayload = result.data;
}Facilitator Client
import { useFacilitator } from "x402-stellar";
const { verify, settle, supported } = useFacilitator({
url: "http://localhost:4022",
});
// Get supported payment kinds
const kinds = await supported();
// Verify a payment
const verifyResult = await verify(paymentPayload, paymentRequirements);
// Settle a payment
const settleResult = await settle(paymentPayload, paymentRequirements);Network Configuration
import { STELLAR_NETWORKS } from "x402-stellar";
const testnetConfig = STELLAR_NETWORKS["stellar-testnet"];
console.log(testnetConfig.horizonUrl);
// https://horizon-testnet.stellar.orgExports
x402-stellar- Main entry point with all exportsx402-stellar/types- Types and Zod schemas onlyx402-stellar/shared- Shared utilities (base64, JSON)x402-stellar/verify- Facilitator client
License
MIT
