• Fetches a MaybeAccount from the provided RPC client and address by using GetAccountInfoApi.getAccountInfo | getAccountInfo under the hood with the jsonParsed encoding.

    It may also return a MaybeEncodedAccount if the RPC client does not know how to parse the account at the requested address. In any case, the expected data type should be explicitly provided as the first type parameter.

    Type Parameters

    • TData extends object

      The expected type of this account's data.

    • TAddress extends string = string

      Supply a string literal to define an account having a particular address.

    Parameters

    Returns Promise<MaybeAccount<TData & {
        parsedAccountMeta?: {
            program: string;
            type?: string;
        };
    }, TAddress> | MaybeEncodedAccount<TAddress>>

    type TokenData = { mint: Address; owner: Address };
    const myAccount = await fetchJsonParsedAccount<TokenData>(rpc, myAddress);
    myAccount satisfies MaybeAccount<TokenData> | MaybeEncodedAccount;

    // With custom configuration.
    const myAccount = await fetchJsonParsedAccount<TokenData>(rpc, myAddress, {
    abortSignal: myAbortController.signal,
    commitment: 'confirmed',
    });