Use cases
- Display the total amount committed to your sale
- Show the number of unique participants
- List recent commitments to create a live activity feed
- For auctions: show the current estimated clearing price
Data freshness and limits
The commitment data API reads directly from the sale contract, but it is designed for displaying live sale activity rather than for reconciliation. Keep the following characteristics in mind:- Caching: Responses are cached for about a minute, so newly confirmed commitments may take up to that long to appear.
- Recent commitments only: The
Commitmentsarray contains only the most recent 100 commitments. There is no pagination, so on larger sales this window will not include every commitment. - Clearing price: The auction clearing price is computed off-chain by Sonar. The
ClearingPriceNumeratorandClearingPriceDenominatorfields are the source of truth for it; it is not derived on-chain.
For a complete or exact per-entity total (for example, on large sales, or when reconciling a specific entity’s committed amount), read the committed amount directly from the sale contract rather than relying on the API’s 100-record window. See smart contract operations for how to query the contract directly.
Polling, not webhooks
There is no webhook or subscription for commitment updates. Polling the endpoint (or theuseCommitmentData hook, which accepts a pollingIntervalMs) is the intended pattern for keeping displayed data fresh.
Using the React hook
The simplest way to fetch commitment data is with theuseCommitmentData hook from @echoxyz/sonar-react.
pollingIntervalMs is not provided, the data is fetched once when the component mounts.
Reference docs for the useCommitmentData hook.
Formatting amounts
TheTotalCommitmentAmount and individual commitment amounts are returned as strings in the payment token’s smallest unit (e.g. USDC has 6 decimals, so the smallest unit is 1/1,000,000 of a USDC).
Use PaymentTokenDecimals to format these values for display:
Displaying recent commitments
TheCommitments array contains individual commitments sorted by creation time (most recent first). Each commitment includes:
SaleSpecificEntityID: The entity that made the commitmentCreatedAt: When the commitment was made (ISO 8601 timestamp)Amounts: Array of amounts committed per wallet and payment token
Auction clearing price
For English auction sales, the response includes the current estimated clearing price:ClearingPriceNumeratorandClearingPriceDenominator: The clearing price as a fraction (in smallest units of the payment token per smallest unit of the offered token)ClearingPriceMicroUSD: The clearing price in micro-USD (1 USD = 1,000,000 micro-USD) per human-readable offered token
ClearingPriceMicroUSD field is convenient for display purposes, but may lose precision. For machine-readable use cases (e.g., passing to a contract or performing calculations), use the ClearingPriceNumerator and ClearingPriceDenominator fraction instead.
Using the core library directly
If you’re not using React, you can call the API directly usingSonarClient:
readCommitmentData function.
API reference
For more details on the response format and available fields, see:- readCommitmentData - Core library function
- useCommitmentData - React hook
- ReadCommitmentData API - HTTP API reference