• Fetch a raw account and decode its data using the provided decoder.

    This is the core building block for all typed account fetchers. It handles the RPC call, base64 decoding, and applies the decoder.

    Type Parameters

    • T

      The decoded account type.

    Parameters

    • transport: HttpTransport

      HTTP transport for RPC calls.

    • pubkey: never

      Account public key to fetch.

    • decoder: ((data: Uint8Array<ArrayBufferLike>) => T)

      Function that decodes raw bytes into type T.

        • (data): T
        • Parameters

          • data: Uint8Array<ArrayBufferLike>

          Returns T

    • opts: {
          commitment?: Commitment;
      } & CallOptions = {}

      RPC options (commitment, call overrides).

    Returns Promise<DecodedAccountResult<T> | null>

    Decoded result, or null if the account doesn't exist.

    import { getDecodedAccount } from '@oobe-protocol-labs/synapse-client-sdk/accounts';
    import { decodeTokenAccount } from '@oobe-protocol-labs/synapse-client-sdk/decoders';

    const result = await getDecodedAccount(transport, pubkey, decodeTokenAccount);
    if (result) console.log(`Amount: ${result.decoded.amount}`);

    1.1.0