Skip to content

Interface: TokenService

TokenService interface

Methods

getAllTokenHolders()

ts
getAllTokenHolders(options?): Promise<TokenAccountWithBalance[]>;

Parameters

ParameterType
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

ParameterTypeDescription
ownerstring | AddressThe owner address

Returns

Promise<Address>

The associated token account address


getBalance()

ts
getBalance(owner?): Promise<number>;

Parameters

ParameterType
owner?string | Address

Returns

Promise<number>


getTokenAccountForAddress()

ts
getTokenAccountForAddress(owner): Promise<TokenAccountWithBalance | null>;

Parameters

ParameterType
ownerstring | 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

ParameterTypeDescription
params{ amount: number | bigint; from?: TransactionSigner; payerForATA?: string | Address | TransactionSigner; to: string | Address; }Transfer parameters
params.amountnumber | bigintAmount in token base units (number or bigint)
params.from?TransactionSignerOptional sender TransactionSigner. If not provided, uses wallet from client.
params.payerForATA?string | Address | TransactionSignerOptional 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.tostring | AddressRecipient address

Returns

Promise<Instruction<string, readonly (AccountLookupMeta<string, string> | AccountMeta<string>)[]>[]>

Array of instructions (create ATA instruction if needed, then transfer instruction)