PaymentRequiredError containing a payment quote. You then pay and re-query using executeWithPayment().
How It Works
Basic Example
Pay and Re-Query
After catchingPaymentRequiredError, process the payment and use executeWithPayment() to retry:
executeWithPayment
TheexecuteWithPayment() method on QueryBuilder retries a query with payment proof:
Parameters
| Parameter | Type | Description |
|---|---|---|
quoteId | string | Quote ID from the PaymentRequiredError |
paymentProof | string | Transaction hash from the payment |
network | string | Optional network identifier |
Return Value
ReturnsQueryResponse<T> with the same structure as execute().
Error Types
Type-Safe Payment Handling
Use Cases
| Use Case | Description |
|---|---|
| Premium Content | Charge for access to exclusive data |
| API Monetization | Monetize data access with per-query pricing |
| Cost Recovery | Recover computational costs for expensive queries |
| Tiered Access | Free basic queries, paid for detailed fields |
| Data Marketplace | Build marketplaces where data providers set prices |
Next Steps
Cost Estimation
Estimate operation costs
Write Payments
Write operation payments