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; 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.tostring | AddressRecipient address

Returns

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

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