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 libraryIOTA_FRAMEWORK_ADDRESS: The address for the IOTA FrameworkIOTA_SYSTEM_ADDRESS: The address for the IOTA System moduleIOTA_CLOCK_OBJECT_ID: The address for theiota::clock::ClockobjectIOTA_SYSTEM_STATE_OBJECT_ID: The address for theIotaSystemStateobject
Formatters
You can use the following helpers to format various values:
formatAddressformatDigestnormalizeStructTagnormalizeIotaAddressnormalizeIotaObjectIdnormalizeIotaNSName
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).
isValidIotaAddressisValidIotaObjectIdisValidTransactionDigestisValidIotaNSName
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