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

    The UserData class provides HTTP access to user public-key data and local helpers for the messages used by authenticated Aftermath requests.

    Hierarchy (View Summary)

    Index
    config: CallerConfig

    The mutable configuration used for subsequent requests.

    termsAndConditionsMessage: "Aftermath Terms and Conditions"

    The single message every wallet signs once per session to prove ownership. af-fe decodes the personal-message bytes and compares this text byte for byte, so it must stay exactly this string: no JSON wrapper, action, date, or trailing whitespace.

    • Generates a simple message object that the user should sign to confirm their agreement with the Terms and Conditions of the service.

      Returns { action: string }

      An object with an action property set to "SIGN_TERMS_AND_CONDITIONS". This method does not make a network request.

      af-fe no longer accepts the {action:...} wrapper and rejects it with error 2034. Sign createTermsAndConditionsMessage instead.

    • Returns the canonical Terms and Conditions message to sign. Sign it as a personal message over its UTF-8 bytes and reuse the signature for the whole session: it is the one credential af-fe verifies for referrals, rewards, stop/twap order datas, collateral/order history, the websocket user subscription, and gas-pool sponsorship.

      Returns string

      The exact string to sign. This method does not make a network request.

      const message = new UserData().createTermsAndConditionsMessage();
      const { bytes, signature } = await signPersonalMessage(
      new TextEncoder().encode(message)
      );
    • Builds the legacy account-creation message object locally.

      This method does not make a network request. Current authenticated requests use createTermsAndConditionsMessage() instead.

      Returns { action: string }

      An object with action: "CREATE_USER_ACCOUNT".

      const userData = new UserData();
      const msgToSign = userData.createUserAccountMessageToSign();
      console.log(msgToSign.action); // "CREATE_USER_ACCOUNT"
      // The user can then sign msgToSign with their private key.
    • Creates or updates the stored public key for a wallet through the backend. This method sends the supplied signed bytes and signature; it does not sign the message or make a transaction.

      For the current authentication flow, sign the exact value returned by createTermsAndConditionsMessage() as a personal message over its UTF-8 bytes, then pass those bytes and the resulting signature in inputs.

      Parameters

      Returns Promise<boolean>

      true when the backend stores the key. false is also a valid backend response.

      AftermathTransportError when the API request or response fails.

      const created = await userData.createUserPublicKey({
      walletAddress: "0x<address>",
      bytes: "0x<message_as_bytes>",
      signature: "0x<signature>"
      });
      console.log("Was public key created?", created);
    • Retrieves the stored user public key (if any) for a given wallet address.

      Parameters

      • inputs: ApiUserDataPublicKeyBody

        An object implementing ApiUserDataPublicKeyBody, containing the user's wallet address.

      Returns Promise<string | undefined>

      A promise that resolves to a string representation of the user's public key, or undefined if none is found.

      AftermathTransportError when the API request or response fails.

      const afSdk = await Aftermath.create({ network: "MAINNET" });

      const userData = afSdk.UserData();

      const pubkey = await userData.getUserPublicKey({
      walletAddress: "0x<address>"
      });
      console.log(pubkey); // "0x<hex_public_key>" or undefined
    • Returns the canonical Aftermath API host for a Sui network.

      To target a custom or local host, pass baseUrl in CallerConfig to the constructor instead.

      Parameters

      • network: SuiNetwork

        The Sui network whose host to return.

      Returns string

      The network's HTTPS or local HTTP API host.