Kit
Functions

fetchEncodedAccounts

fetchEncodedAccounts<TAddresses, TWrappedAddresses>(rpc, addresses, config?): Promise<{ [P in string | number | symbol]: MaybeEncodedAccount<TAddresses[P<P>]> }>

Fetches an array of MaybeEncodedAccounts from the provided RPC client and an array of addresses.

It uses the getMultipleAccounts RPC method under the hood with base64 encodings and an additional configuration object can be provided to customize the behavior of the RPC call.

Type Parameters

Type ParameterDefault typeDescription
TAddresses extends string[]string[]Supply an array of string literals to define accounts having particular addresses.
TWrappedAddresses extends { [P in string | number | symbol]: Address<TAddresses[P<P>]> }{ [P in string | number | symbol]: Address<TAddresses[P<P>]> }-

Parameters

ParameterType
rpcRpc<GetMultipleAccountsApi>
addressesTWrappedAddresses
config?FetchAccountsConfig

Returns

Promise<{ [P in string | number | symbol]: MaybeEncodedAccount<TAddresses[P<P>]> }>

Example

const myAddressA = address('1234..5678');
const myAddressB = address('8765..4321');
const [myAccountA, myAccountB] = await fetchEncodedAccounts(rpc, [myAddressA, myAddressB]);
myAccountA satisfies MaybeEncodedAccount<'1234..5678'>;
myAccountB satisfies MaybeEncodedAccount<'8765..4321'>;
 
// With custom configuration.
const [myAccountA, myAccountB] = await fetchEncodedAccounts(rpc, [myAddressA, myAddressB], {
    abortSignal: myAbortController.signal,
    commitment: 'confirmed',
});

On this page