Skip to content

useRecords

Usage

connect() must be called and WalletConnect session must be initiated before account information will be returned.

The useRecords hook is a React Hook wrapper around the getRecords function If an address is provided, the wallet will return that address’ records if that address is in the wallet. Otherwise, it will return the currently selected account’s records. If the multisig flag is true, the sdk will not fetch until an address is present.

import { EventsFilter, useEvents, UseEventsOptions } from '@puzzlehq/sdk';
type UseRecordsParams = {
address?: string;
multisig?: boolean;
filter?: RecordsFilter,
page?: number,
}
const filter: RecordsFilter = {
programId: 'credits.aleo';
type: 'unspent';
}
const { fetchPage, records, error, loading, page, pageCount } = useRecords({filter);

Return Value

{
fetchPage: () => void,
records?: RecordWithPlaintext[],
loading: boolean,
error?: string,
page?: number,
pageCount?: number
};

Additional related types can be found on the records page.