fetchTokenAccounts
Fetch all the the token accounts for a given mint and owner Address. Automatically fetching
the Mint account itself and calculating the total balance of all the owner's token accounts.
Example
Type Parameters
| Type Parameter | Default type |
|---|---|
TMintAddress extends string | string |
TOwner extends string | string |
Parameters
| Parameter | Type | Description |
|---|---|---|
rpc | Rpc<GetTokenAccountsByOwnerApi & GetAccountInfoApi> | - |
mint | | Address<TMintAddress> | Account<Mint> | - |
owner | Address<TOwner> | - |
config | { abortSignal?: AbortSignal; commitment?: Commitment; dataSlice?: Readonly<{ length: number; offset: number; }>; minContextSlot?: bigint; } | - |
config.abortSignal? | AbortSignal | - |
config.commitment? | Commitment | Fetch the details of the accounts as of the highest slot that has reached this level of commitment. |
config.dataSlice? | Readonly<{ length: number; offset: number; }> | Define which slice of the accounts' data you want the RPC to return. Use this to save network bandwidth and encoding time when you do not need the entire buffer. Data slicing is only available for "base58", "base64", and "base64+zstd" encodings. |
config.minContextSlot? | bigint | Prevents accessing stale data by enforcing that the RPC node has processed transactions up to this slot |
Returns
Promise<{
accounts: Account<Token>[];
mint: Account<Mint>;
totalBalance: bigint;
}>