Skip to content

AssetsService

Source

Balance queries and token transfers via BlockchainGateway.

transfer

ts
transfer(
  fromAddress: Address,
  toAddress: Address,
  amount: bigint,
  wallet: Wallet,
  passwordProvider: PasswordProvider,
  phloLimit?: number
): Promise<string | undefined>

Transfers ASI tokens from one address to another by constructing, signing, and submitting a deploy. Both addresses are validated before submission.

Parameters:

NameTypeRequiredDescription
fromAddressAddressYesSender address. Must pass validateAddress().
toAddressAddressYesRecipient address. Must pass validateAddress().
amountbigintYesAmount in atomic units. Must be greater than zero.
walletWalletYesWallet used to sign the transfer deploy.
passwordProviderPasswordProviderYesAsync callback returning the wallet password.
phloLimitnumberNoGas limit. Defaults to DEFAULT_PHLO_LIMIT from config.

Returns: Promise<string | undefined> — deploy ID on success.

Throws:

  • Error("AssetsService.transfer: Invalid 'fromAddress': ${errorCode}") — sender address validation failed.
  • Error("AssetsService.transfer: Invalid 'toAddress': ${errorCode}") — recipient address validation failed.
  • Error("AssetsService.transfer: Transfer amount must be greater than zero") — if amount ≤ 0.
  • Error("AssetsService.transfer: Invalid block number") — if the blockchain returns an invalid block number.
  • Error("AssetsService.transfer: ${message}") — wraps signer or gateway errors.

getASIBalance

ts
getASIBalance(address: Address): Promise<bigint>

Retrieves the ASI balance for an address using an exploratory deploy.

Parameters:

NameTypeRequiredDescription
addressAddressYesAddress to query. Must pass validateAddress().

Returns: Promise<bigint> — balance in atomic units. Returns BigInt(0) on any error or if the address has no balance.

ASI:Chain DevNet - Development Network