The @iota/iota-sdk/utils package
This package contains some utilities that simplify common operations when working with the IOTA TypeScript SDK.
Constants
A set of constants exported for common uses cases:
- NANOS_PER_IOTA: The conversion rate for NANOS to IOTA (1,000,000,000)
- IOTA_DECIMALS: the number of decimals you must shift a NANOS value to convert it to IOTA (- 9)
- IOTA_ADDRESS_LENGTH: The number of bytes in an IOTA address (32)
- MOVE_STDLIB_ADDRESS: The address for the IOTA Move standard library
- IOTA_FRAMEWORK_ADDRESS: The address for the IOTA Framework
- IOTA_SYSTEM_ADDRESS: The address for the IOTA System module
- IOTA_CLOCK_OBJECT_ID: The address for the- iota::clock::Clockobject
- IOTA_SYSTEM_STATE_OBJECT_ID: The address for the- IotaSystemStateobject
Formatters
You can use the following helpers to format various values:
- formatAddress
- formatDigest
- normalizeStructTag
- normalizeIotaAddress
- normalizeIotaObjectId
- normalizeIotaNSName
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).
- isValidIotaAddress
- isValidIotaObjectId
- isValidTransactionDigest
- isValidIotaNSName
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