Skip to content

API ReferenceReact provider and hooksFunction

useCreditedTokens()

function useCreditedTokens(params?): UseCreditedTokensResult;

Fetches the credited-token collection for dynamic-LOC selection.

Pages are fetched progressively and retained in fetch order; items is every page flattened. Each page is held fresh for five minutes. Omitting params.limit applies the SDK’s default collection page size rather than fetching the whole collection at once.

Parameters

ParameterTypeDescription
params?GetCreditedTokensParamsPagination and filter options forwarded to getCreditedTokens. Omit for the default first page.

Returns

UseCreditedTokensResult

The progressive collection envelope: pages and flattened items, hasNextPage and fetchNextPage to follow the exact cursor, separate error (first page) and nextPageError (later pages) so a transient later failure does not discard what already loaded, and retry.

Throws

Error when rendered outside <AnvilProvider>, by way of useAnvilSDK.

Example

export function CreditedTokenSelect() {
const { items, isLoading } = useCreditedTokens();
if (isLoading) return <p>Loading credited tokens…</p>;
return (
<select>
{items.map(({ token }) => (
<option key={token.address}>{token.symbol}</option>
))}
</select>
);
}