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 | The owner address |
Returns
Promise<Address>
The associated token account address
getBalance()
ts
getBalance(owner?): Promise<number>;Parameters
| Parameter | Type |
|---|---|
owner? | string | Address |
Returns
Promise<number>
getTokenAccountForAddress()
ts
getTokenAccountForAddress(owner): Promise<TokenAccountWithBalance | null>;Parameters
| Parameter | Type |
|---|---|
owner | string | Address |
Returns
Promise<TokenAccountWithBalance | null>
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; 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.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)