• Fetch all token accounts owned by a wallet, optionally filtered by mint.

    Parameters

    • transport: HttpTransport

      HTTP transport.

    • owner: never

      Wallet public key.

    • Optionalmint: undefined

      Token mint to filter by (optional).

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

      RPC options. Include programId to target Token-2022 specifically.

    Returns Promise<FetchedTokenAccount[]>

    Array of decoded token accounts.

    const accounts = await fetchTokenAccountsByOwner(transport, walletPubkey, usdcMint);
    for (const a of accounts) console.log(`${a.address}: ${a.decoded.amount}`);

    1.1.0