Skip to main content
OnDB uses the x402 payment protocol for cost handling. When a write or read operation requires payment, the server returns a 402 response with a payment quote. The SDK handles this automatically via the payment callback.

How Pricing Works

Costs are determined server-side based on:

Inspecting Costs via Payment Callback

The payment callback receives an X402Quote with full cost details:

Estimating Batch Costs

For batch operations, the payment callback is invoked once for the entire batch. The quote reflects the total cost:

Retention Costs

Use getRetentionCost() to estimate ongoing storage costs for your collections:

Next Steps

Write Payments

Execute payments

PriceIndex

Value-based pricing