@aroha-sdk/settlement
v1.3.0
Published
Pluggable settlement layer for the Aroha Protocol — null, API-key, quota, escrow, Stripe, and Postgres backends
Readme
@aroha-sdk/settlement
Pluggable billing adapters for Aroha agents — from free to quota-enforced to escrow-based settlement.
Install
npm install @aroha-sdk/settlementQuick example
import { NullSettlement, QuotaSettlement, EscrowSettlement } from "@aroha-sdk/settlement";
// No-op — useful for open/free agents
const settlement = new NullSettlement();
// Enforce a per-agent spending cap derived from the mandate
const settlement = new QuotaSettlement({
getLimit: (mandateConstraints) => mandateConstraints.spendLimitUsd,
onExceeded: (agentDID, used, limit) => {
throw new Error(`Mandate spending cap exceeded: $${used} > $${limit}`);
},
});
// Escrow-backed settlement for production financial flows
const settlement = new EscrowSettlement({
escrowContractAddress: "0xabc...",
signerPrivateKey: process.env.ESCROW_SIGNER_KEY!,
});
// Attach to your server
serve({ name: "my-agent", did, privateKey, settlement, onRequest });Why this exists in the mandate chain
Spending limits are one dimension of mandate scope. The settlement layer is where those limits are operationally enforced — checking actual charges against the spendLimitUsd constraint in the mandate before committing a transaction.
API
NullSettlement— no-op adapter. All charges pass through. Use for free or internally-trusted agents.QuotaSettlement(opts)— enforce per-call and cumulative spending caps derived from mandate constraints.EscrowSettlement(opts)— on-chain escrow using the ArohaEscrow Solidity contract. Alpha — not for production financial use.ApiKeySettlement(opts)— simple API-key-based billing for SaaS-style monetization.
License
MIT
