@stellect/core
v0.1.0
Published
x402 payment engine, service registry, and budget guard for Stellect
Downloads
16
Maintainers
Readme
@stellect/core
x402 payment engine, service registry, and on-chain budget guard for Stellect.
Install
npm install @stellect/coreUsage
X402Client
Handles the full HTTP 402 payment flow automatically:
import { X402Client } from '@stellect/core';
const client = new X402Client({
signer: {
address: 'GPUBLIC...',
signAuthEntry: async (preimage) => ({
signedAuthEntry: '...',
signerAddress: 'GPUBLIC...',
}),
},
});
// Fetch with automatic payment
const result = await client.request('http://localhost:4021/api/weather?city=Istanbul');
// result.paid === true if payment was made
// result.response contains the API dataServiceRegistry
Discover x402 services from the bazaar:
import { ServiceRegistry } from '@stellect/core';
const registry = new ServiceRegistry({
registryUrl: 'http://localhost:4021/api/services',
});
const services = await registry.getServices();
const weather = await registry.getService('weather-openweathermap');
const dataServices = await registry.filterByCategory('data');BudgetGuard
On-chain spending policy enforcement via Soroban:
import { BudgetGuard } from '@stellect/core';
const guard = new BudgetGuard({ contractId: 'C...' });
const allowed = await guard.checkSpend(agent, '10000', service);Gracefully degrades to allow-all when no contract is deployed.
Tests
npm test # 23 tests: x402-client, service-registry, budget-guard, e2e-paymentLicense
MIT
