createClientWithInterfacesFromRpc

function createClientWithInterfacesFromRpc<TRpc>(
    rpc,
): ClientInterfacesFromRpc<TRpc>;

Creates a client from a raw Rpc object, filling in whichever client interfaces the RPC supports.

The returned object implements a ClientWithGetMinimumBalance when the RPC supports the GetMinimumBalanceForRentExemptionApi, and a ClientWithFetchAccounts when it supports the GetAccountInfoApi and/or the GetMultipleAccountsApi. The return type reflects the interfaces available on the provided RPC, so you only get the interfaces your RPC can actually back.

Note that this does not create a fully-fledged Kit client — it only wraps the RPC in the account interfaces above. To build a complete client, use createClient().use(solanaRpc(...)) instead, which additionally exposes the underlying RPC and other capabilities.

Type Parameters

Parameters

ParameterTypeDescription
rpcTRpcA raw Rpc object. The interfaces filled in on the returned client depend on which RPC methods it supports.

Returns

ClientInterfacesFromRpc<TRpc>

Example

// With an RPC supporting both APIs, the client implements both interfaces.
const client = createClientWithInterfacesFromRpc(rpc);
const rentExemptBalance = await client.getMinimumBalance(100);
const accounts = await client.fetchAccounts([addressA, addressB]);

On this page