The @mysten/sui/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 librarySUI_FRAMEWORK_ADDRESS
: The address for the Sui FrameworkSUI_SYSTEM_ADDRESS
: The address for the Sui System moduleSUI_CLOCK_OBJECT_ID
: The address for thesui::clock::Clock
objectSUI_SYSTEM_STATE_OBJECT_ID
: The address for theSuiSystemState
object
Formatters
You can use the following helpers to format various values:
formatAddress
formatDigest
normalizeStructTag
normalizeSuiAddress
normalizeSuiObjectId
normalizeSuiNSName
normalizeSuiNSName
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
isValidSuiNSName
Encoding
The following methods are re-exported to help with converting between commonly used encodings
fromHex
: Deserializes a hex string to a Uint8ArraytoHex
: Serializes a Uint8Array to a hex stringfromBase64
: Deserializes a base64 string to a Uint8ArraytoBase64
: Serializes a Uint8Array to a base64 string