createClientWithFetchAccountsFromRpc

function createClientWithFetchAccountsFromRpc(
    rpc,
): ClientWithFetchAccounts;

Creates a ClientWithFetchAccounts from a raw Rpc object.

The returned client fetches the encoded content of accounts from their addresses, choosing the most appropriate RPC method for the request. A single account is fetched via the getAccountInfo RPC method when available, whilst multiple accounts are fetched via the getMultipleAccounts RPC method. When only one of the two methods is available, it is used for both cases. Providing an Rpc that supports both methods enables the most appropriate behaviour.

This is a convenience helper for consumers that only have a raw Rpc object rather than a Kit client. If you are building a full client, prefer composing it with a plugin such as solanaRpc (i.e. createClient().use(solanaRpc(...))), which provides account fetching amongst other capabilities.

Parameters

ParameterTypeDescription
rpc| Rpc<GetAccountInfoApi> | Rpc<GetMultipleAccountsApi>An object that supports the GetMultipleAccountsApi and/or the GetAccountInfoApi of the Solana RPC API.

Returns

ClientWithFetchAccounts

Example

const client = createClientWithFetchAccountsFromRpc(rpc);
const accounts = await client.fetchAccounts([addressA, addressB]);

On this page