Interface: TokenService
TokenService interface
Methods
getAllTokenHolders()
ts
getAllTokenHolders(options?): Promise<TokenAccountWithBalance[]>;Parameters
| Parameter | Type |
|---|---|
options? | { excludePdaAccounts?: boolean; includeZeroBalance?: boolean; } |
options.excludePdaAccounts? | boolean |
options.includeZeroBalance? | boolean |
Returns
Promise<TokenAccountWithBalance[]>
getATA()
ts
getATA(owner?): Promise<Address>;Get the associated token account address for a given owner.
Parameters
| Parameter | Type | Description |
|---|---|---|
owner? | string | Address | Optional owner address. If not provided, uses the wallet address. |
Returns
Promise<Address>
The associated token account address
Throws
If neither owner nor wallet is provided
getBalance()
ts
getBalance(owner?): Promise<bigint>;Parameters
| Parameter | Type |
|---|---|
owner? | string | Address |
Returns
Promise<bigint>
getBalanceInfo()
ts
getBalanceInfo(owner?): Promise<TokenBalanceInfo>;Parameters
| Parameter | Type |
|---|---|
owner? | string | Address |
Returns
transfer()
ts
transfer(params): Promise<Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]>;Get instruction(s) to transfer SPL tokens from one address to another. May return 1 or 2 instructions depending on whether the recipient's associated token account needs to be created.
Parameters
| Parameter | Type | Description |
|---|---|---|
params | { amount: number | bigint; from?: TransactionSigner; payerForATA?: string | Address | TransactionSigner; to: string | Address; } | Transfer parameters |
params.amount | number | bigint | Amount in token base units (number or bigint) |
params.from? | TransactionSigner | Optional sender TransactionSigner. If not provided, uses wallet from client. |
params.payerForATA? | string | Address | TransactionSigner | Optional payer for creating the recipient's ATA. Can be a TransactionSigner (for full signing) or an Address (for deferred signing scenarios where the payer signs later, e.g., as the transaction fee payer). If not provided, uses the sender as the ATA payer. |
params.to | string | Address | Recipient address |
Returns
Promise<Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]>
Array of instructions (create ATA instruction if needed, then transfer instruction)