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

    It uses the GetMultipleAccountsApi#getMultipleAccounts | 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

    • 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

    Returns Promise<{
        [P in keyof TAddresses]: MaybeEncodedAccount<TAddresses[P]>
    }>

    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',
    });