# The `@mysten/sui/utils` package

> Utility functions for addresses, coins, and common operations in the Sui TypeScript SDK.

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
- `SUI_RANDOM_OBJECT_ID`: The address for the `0x2::random::Random` object

## Formatters

You can use the following helpers to format various values:

- `formatAddress`
- `formatDigest`
- `normalizeStructTag`
- `normalizeSuiAddress`
- `normalizeSuiObjectId`
- `normalizeSuiNSName`
- `normalizeSuiNSName`

## Parsers

You can use the following helpers to parse decimal strings into smallest-unit bigints:

- `parseToUnits`: Parse a decimal string into a `bigint`, given a coin's `decimals`
- `parseToMist`: Parse a SUI decimal string into MIST (9 decimals)

## 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 Uint8Array
- `toHex`: Serializes a Uint8Array to a hex string
- `fromBase64`: Deserializes a base64 string to a Uint8Array
- `toBase64`: Serializes a Uint8Array to a base64 string