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

    The AftermathApi class is a low-level factory and reference point for interacting directly with underlying API modules such as PoolsApi and StakingApi. It binds a configured SuiGrpcClient to the network-specific package and object addresses supplied by the caller.

    Constructing this class performs no network I/O. The accessor methods create helper instances, and those helpers perform requests when their methods run. A helper that needs an omitted address section throws during construction.

    import { AftermathApi, type ConfigAddresses } from "aftermath-ts-sdk";
    import { SuiGrpcClient } from "@mysten/sui/grpc";

    const addresses: ConfigAddresses = {}; // populate for the selected network
    const fullnodeUrl = "https://fullnode.mainnet.sui.io";

    const client = new SuiGrpcClient({
    network: "mainnet",
    baseUrl: fullnodeUrl,
    });

    const afApi = new AftermathApi(client, addresses);
    const suiApi = afApi.Sui();

    Only if you call one of the three legacy helpers listed on AftermathApi.jsonRpcClient do you need to opt into JSON-RPC:

    import { AftermathApi, type ConfigAddresses } from "aftermath-ts-sdk";
    import { SuiGrpcClient } from "@mysten/sui/grpc";
    import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";

    const addresses: ConfigAddresses = {};
    const fullnodeUrl = "https://fullnode.mainnet.sui.io";
    const client = new SuiGrpcClient({
    network: "mainnet",
    baseUrl: fullnodeUrl,
    });
    const jsonRpcClient = new SuiJsonRpcClient({
    url: fullnodeUrl,
    network: "mainnet",
    });

    const afApi = new AftermathApi(client, addresses, jsonRpcClient);
    Index
    • Constructs a new instance of the AftermathApi, binding the given Sui client to the known addresses.

      Parameters

      • client: SuiGrpcClient

        A SuiGrpcClient for on-chain queries and transactions.

      • addresses: ConfigAddresses

        The config addresses (object IDs, package IDs, etc.) for the Aftermath protocol.

      • OptionaljsonRpcClient: SuiJsonRpcClient

        Optional. A SuiJsonRpcClient pointed at the same fullnode. Only used by the three legacy helpers listed on AftermathApi.jsonRpcClient; every other call goes over gRPC via client. Omit it unless you call one of those three — they then throw a descriptive error instead of failing against a deprecated protocol. See AftermathApi.requireJsonRpcClient.

      Returns AftermathApi

    addresses: ConfigAddresses

    Package and object addresses for the same Sui network as client.

    client: SuiGrpcClient

    Sui gRPC client used for low-level on-chain reads and transaction calls.

    jsonRpcClient?: SuiJsonRpcClient

    The remaining JSON-RPC surface of this SDK, and an optional legacy add-on rather than a structural dependency — pass it only if you call one of the three helpers below. When it is absent they throw (see AftermathApi.requireJsonRpcClient); nothing else in the SDK reads it.

    Sui JSON-RPC is deprecated and scheduled for removal from fullnodes in mid-October 2026, but these helpers cannot be expressed with SuiGrpcClient without changing what they return to their callers:

    • Events().fetchCastEventsWithCursorsuix_queryEvents has no SuiGrpcClient equivalent (only the raw ledgerService, with a different filter model).
    • Transactions().fetchTransactionsWithCursorsuix_queryTransactionBlocks has no gRPC equivalent at all (GraphQL or an indexer is required).
    • Sui().fetchSystemState — gRPC has no SuiSystemStateSummary equivalent (core.getCurrentSystemState() carries no validators, and ledgerService.getEpoch's validator shape omits several summary fields). Already @deprecated with no internal callers.

    This list is now exhaustive, and grep -rn "jsonRpcClient\." src/ returns exactly these three call sites. Neither of the first two is reachable from the Aftermath frontend.

    The object readers that used to be on this list — Objects().fetchObject / fetchObjectGeneral / fetchObjectBatch / fetchOwnedObjects and DynamicFields().fetchDynamicFieldObject — are on gRPC as of plan 251. gRPC's json view does differ in shape from JSON-RPC's content.fields (UIDs flattened, nested structs unwrapped, vector<u8> base64-encoded), but that is decidable per read site from the *FieldsOnChain interface already declared there, so no Move type layouts are needed — see GrpcCasting's field-shape primitives.

    helpers: {
        coin: typeof CoinApi;
        dynamicFields: typeof DynamicFieldsApiHelpers;
        events: typeof EventsApiHelpers;
        inspections: typeof InspectionsApiHelpers;
        objects: typeof ObjectsApiHelpers;
        sui: typeof SuiApi;
        transactions: typeof TransactionsApiHelpers;
        wallet: typeof WalletApi;
    } = ...

    Static helper references for quick usage without instantiating the class.

    Type Declaration

    • coin: typeof CoinApi

      Low-level direct coin operations, separate from the higher-level Coin class.

    • dynamicFields: typeof DynamicFieldsApiHelpers

      Helpers for accessing or iterating over dynamic fields in Sui objects.

    • events: typeof EventsApiHelpers

      Helpers for working with Sui events and pagination.

    • inspections: typeof InspectionsApiHelpers

      Helpers for reading on-chain data in an "inspection" manner (designed for Summaries).

    • objects: typeof ObjectsApiHelpers

      Helpers for retrieving and parsing Sui objects by ID or type.

    • sui: typeof SuiApi

      Low-level Sui chain data ops, separate from the higher-level Sui class.

    • transactions: typeof TransactionsApiHelpers

      Helpers for reading transaction data (by digest, query, etc.).

    • wallet: typeof WalletApi

      Helper for wallet-based operations, separate from the main Wallet classes.

    • Returns the optional AftermathApi.jsonRpcClient, throwing a descriptive error when it was not supplied.

      Used by the three helpers that have no SuiGrpcClient equivalent. The throw is deliberate: these helpers cannot degrade to an empty result without silently lying to their callers, and JSON-RPC is scheduled for removal from Sui fullnodes in mid-October 2026, so a missing client is a configuration error worth naming rather than hiding.

      Parameters

      • methodName: string

        The public helper the caller invoked, e.g. "Events().fetchCastEventsWithCursor". Named in the error message.

      Returns SuiJsonRpcClient

      The configured JSON-RPC client.

      If no jsonRpcClient was passed to the constructor.

    • Attempts to decode a Move error message into a structured error code, package ID, module name, and descriptive error string.

      Parameters

      • inputs: { errorMessage: string }

        An object containing the raw errorMessage.

      Returns TranslatedMoveError | undefined

      An object with errorCode, packageId, module, and error if translation is successful, or undefined.

      const errorDecoded = afApi.translateMoveErrorMessage({ errorMessage: "MoveAbort at ..." });
      if (errorDecoded) {
      console.log(errorDecoded.errorCode, errorDecoded.error);
      }