Kit
Functions

fetchEncodedAccount

fetchEncodedAccount<TAddress>(rpc, address, config?): Promise<MaybeEncodedAccount<TAddress>>

Fetches a MaybeEncodedAccount from the provided RPC client and address.

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

Type Parameters

Type ParameterDefault typeDescription
TAddress extends stringstringSupply a string literal to define an account having a particular address.

Parameters

ParameterType
rpcRpc<GetAccountInfoApi>
addressAddress<TAddress>
config?FetchAccountConfig

Returns

Promise<MaybeEncodedAccount<TAddress>>

Example

const myAddress = address('1234..5678');
const myAccount: MaybeEncodedAccount<'1234..5678'> = await fetchEncodedAccount(rpc, myAddress);
 
// With custom configuration.
const myAccount: MaybeEncodedAccount<'1234..5678'> = await fetchEncodedAccount(rpc, myAddress, {
    abortSignal: myAbortController.signal,
    commitment: 'confirmed',
});

On this page