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 a 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::Clock
objectIOTA_SYSTEM_STATE_OBJECT_ID
: The address for theIotaSystemState
object
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 Uint8ArraytoHEX
: Serializes a Uint8Array to a hex stringfromB64
: Deserializes a base64 string to a Uint8ArraytoB64
: Serializes a Uint8Array to a base64 string
Feedback Form