TypeScript SDK
Utils

The @msyten/sui.js/utils package

This package contains some utilities that simplify common operations when working with the Sui Typescript SDK.

Constants

A set of constants exported for common uses cases:

  • MIST_PER_SUI: The conversion rate for MIST to SUI (1,000,000,000)
  • SUI_DECIMALS: the number of decimals you must shift a MIST value to convert it to SUI (9)
  • SUI_ADDRESS_LENGTH: The number of bytes in a Sui address (32)
  • MOVE_STDLIB_ADDRESS: The address for the Sui Move standard library
  • SUI_FRAMEWORK_ADDRESS: The address for the Sui Framework
  • SUI_SYSTEM_ADDRESS: The address for the Sui System module
  • SUI_CLOCK_OBJECT_ID: The address for the sui::clock::Clock object
  • SUI_SYSTEM_STATE_OBJECT_ID: The address for the SuiSystemState object

Formatters

You can use the following helpers to format various values:

  • formatAddress
  • formatDigest
  • normalizeStructTag
  • normalizeSuiAddress
  • normalizeSuiObjectId

Validators

You can use the following helpers to validate the format of various values (this only validates that the value is in the correct format, but does not validate the value is valid for a specific use case, or exists on chain).

  • isValidSuiAddress
  • isValidSuiObjectId
  • isValidTransactionDigest

Encoding

The following methods are re-exported to help with converting between commonly used encodings

  • fromHEX: Serializes a Uint8Array to a hex string
  • toHEX: Deserializes a hex string to a Uint8Array
  • fromB64: Serializes a Uint8Array to a base64 string
  • toB64: Deserializes a base64 string to a Uint8Array