aftermath-ts-sdk - v3.3.3
    Preparing search index...

    Queries transaction history and builds or converts Sui transaction data.

    Transaction history still uses the optional JSON-RPC client. Gas estimation uses the configured gRPC client and reference gas price. Static conversion and transaction-builder methods run locally and do not perform network I/O.

    Index
    • Builds the transaction kind and encodes its bytes as base64.

      This helper performs no direct network request. It asks the Sui transaction builder for onlyTransactionKind: true, using the configured gRPC client as the builder client when input resolution requires it. An absent transaction is treated as no work and returns undefined.

      Parameters

      • inputs: { tx: Transaction | undefined }

        The transaction to build, or undefined.

      Returns Promise<string | undefined>

      Base64 transaction-kind bytes, or undefined when tx is absent.

      Errors from the Sui transaction builder.

    • Serializes a transaction, estimating gas unless it is already sponsored.

      A sponsored transaction is serialized locally with toJSON() and does not call the gRPC client. An unsponsored transaction performs the same gRPC gas simulation and reference-price lookup as fetchSetGasBudgetForTx before serialization. The input may be an existing transaction or a promise for one.

      Parameters

      • inputs: { isSponsoredTx?: boolean; tx: Transaction | Promise<Transaction> }

        The transaction or transaction promise and the sponsorship flag. Set isSponsoredTx to true only when gas has already been supplied by the sponsor.

      Returns Promise<string>

      The serialized transaction string produced by toJSON().

      Errors from the transaction promise, gas estimation, or serialization.

    • Estimates gas with gRPC simulation and applies a safe budget and reference gas price to a transaction.

      This method performs two gRPC requests: it simulates the built transaction and reads the current reference gas price. The budget is the simulation's computation cost plus storage cost, increased by 10% with integer division. Storage rebate and non-refundable storage fee are not included. The method sets both values as bigint on the original transaction and returns that same transaction object. Failed simulations can still provide effects and are used for the gas estimate.

      Parameters

      • inputs: { tx: Transaction }

        The transaction to build and update. The transaction must contain enough information for tx.build to resolve its inputs.

      Returns Promise<Transaction>

      The same transaction after setGasBudget and setGasPrice run.

      Errors from transaction building, gRPC simulation, reference gas price lookup, or missing gas-effect data.

    • Fetches one page of transaction history and returns the next digest cursor.

      This method performs network I/O through the optional JSON-RPC client. It requests input, effects, events, balance changes, and object changes for every returned transaction. The gRPC client has no equivalent for this query, so callers must configure AftermathApi.jsonRpcClient.

      Parameters

      • inputs: { cursor?: string; limit?: number; query: SuiTransactionBlockResponseQuery }

        The JSON-RPC transaction query, optional transaction digest cursor, and page limit. The cursor is the last digest from the previous page.

      Returns Promise<TransactionsWithCursor>

      The transaction responses and nextCursor. nextCursor is null when no later page is available.

      Remaining JSON-RPC surface. suix_queryTransactionBlocks has no gRPC equivalent — Sui's own migration cookbook directs callers to GraphQL or an indexer — so this helper still goes through AftermathApi.jsonRpcClient and will stop working when JSON-RPC is removed from fullnodes (scheduled for mid-October 2026). Prefer the Aftermath API's transaction-history endpoints.

      If no jsonRpcClient was passed to AftermathApi, since it is optional there.

      If the JSON-RPC client is missing or the request fails.

    • Converts service coin data back to a Sui transaction object argument.

      This is a local conversion and performs no network I/O. Input, Result, and NestedResult forms are supported. The { Coin: ObjectId } form is intentionally unsupported by this converter and throws an error.

      Parameters

      • inputs: { serviceCoinData: ServiceCoinData }

        The service coin-data value to convert.

      Returns TransactionObjectArgument

      A Sui transaction object argument.

      An Error when the value uses the unsupported Coin form.

    • Converts legacy V2 service coin data back to a Sui transaction argument.

      This is a local conversion and performs no network I/O. "Gas" becomes { GasCoin: true }; indexed input, result, and nested-result forms keep their numeric indices. The value type must match its key.

      Parameters

      • inputs: { serviceCoinDataV2: ServiceCoinDataV2 }

        The legacy service coin-data value to convert.

      Returns TransactionObjectArgument

      A Sui transaction object argument.

      An Error when the key and index shape are unsupported or do not match.

    • Creates a transaction-builder function with a fixed sender input.

      This factory performs no network I/O. Each returned function creates a new Transaction, sets its sender to walletAddress, and invokes func with the new transaction plus the remaining inputs. func must add commands to inputs.tx; its returned TransactionArgument is ignored.

      Type Parameters

      • Inputs

      Parameters

      • func: (inputs: Inputs) => TransactionArgument

        The callback that receives the new transaction and inputs.

      Returns (inputs: { walletAddress: string } & Omit<Inputs, "tx">) => Transaction

      A function that builds a new transaction with the supplied sender.

      import { AftermathApi } from "aftermath-ts-sdk";
      import type { Transaction } from "@mysten/sui/transactions";

      const build = AftermathApi.helpers.transactions.createBuildTxFunc(
      (inputs: { tx: Transaction; walletAddress: string; amount: bigint }) => {
      const amount = inputs.tx.pure.u64(inputs.amount);
      inputs.tx.moveCall({
      target: "0x2::example::use_amount",
      arguments: [amount],
      });
      return amount;
      }
      );
      const tx = build({
      walletAddress: "0x0000000000000000000000000000000000000000000000000000000000000001",
      amount: 10n,
      });
    • Builds a fully qualified Move call target.

      This is a local string operation and performs no network I/O. It does not validate the address, module, or function segments.

      Parameters

      • packageAddress: string

        The published package address.

      • packageName: string

        The Move module name.

      • functionName: string

        The Move function name.

      Returns `${string}::${string}::${string}`

      A string in the form packageAddress::packageName::functionName.

    • Converts a Sui coin transaction argument to the service coin-data shape.

      This is a local conversion and performs no network I/O. Object or type strings are normalized with 64-hex-digit leading zeroes. Input, result, and nested-result arguments keep their indices. Gas coin arguments cannot be represented by ServiceCoinData and throw instead.

      Parameters

      • inputs: { coinTxArg: string | {} | {} | {} | {} | TransactionObjectArgument }

        The object ID or transaction argument to convert.

      Returns ServiceCoinData

      A ServiceCoinData object with Coin, Input, Result, or NestedResult.

      An Error for gas coins and unsupported argument kinds.

    • Converts a Sui coin transaction argument to the legacy V2 service shape.

      This is a local conversion and performs no network I/O. Input, result, and nested-result indices are preserved. A gas coin is represented by the string "Gas"; this V2 shape does not accept an object ID string.

      Parameters

      • inputs: { coinTxArg: {} | {} | {} | {} | TransactionObjectArgument }

        The transaction argument to convert.

      Returns ServiceCoinDataV2

      "Gas", or an Input, Result, or NestedResult object.

      An Error when the argument uses an unsupported shape or kind.

    • Adds a Sui coin-split Move call to a transaction.

      This is a local transaction builder and performs no network I/O. It adds 0x2::coin::split<CoinType> to tx, using coinId as the source coin and amount as a u64 in the coin's smallest on-chain unit. The transaction is mutated in place and still needs gas, signing, and execution by the caller.

      Parameters

      • inputs: { amount: bigint; coinId: string; coinType: string; tx: Transaction }

        The transaction, coin Move type, source coin object ID, and amount in the coin's smallest unit.

      Returns TransactionResult

      The transaction argument returned by moveCall.

      Errors from the Sui transaction builder.

    • Copies sender, expiration, and gas metadata from one transaction to another.

      This is a local transaction operation and performs no network I/O. It copies sender, expiration, gasData.owner, gasData.payment, and gas values when they are bigint. String gas budget and price values are skipped because the transaction setters require numeric values here. Fields absent from initTx are not cleared from newTx.

      Parameters

      • inputs: { initTx: Transaction; newTx: Transaction }

        The source transaction and the transaction to update.

      Returns void

      Nothing. newTx is mutated in place.

      Errors from the destination transaction setters.