Private
Readonly
dataReturn whether Hex instances are equal. Hex instances are considered equal if their underlying byte data is identical.
The Hex instance to compare to.
true if the Hex instances are equal, false if not.
Static
fromStatic
fromStatic
isCheck if the string is valid hex.
A hex string representing byte data.
valid = true if the string is valid, false if not. If the string is not valid, invalidReason and invalidReasonMessage will be set explaining why it is invalid.
NOTE: Do not use this class when working with account addresses, use AccountAddress.
NOTE: When accepting hex data as input to a function, prefer to accept HexInput and then use the static helper methods of this class to convert it into the desired format. This enables the greatest flexibility for the developer.
Hex is a helper class for working with hex data. Hex data, when represented as a string, generally looks like this, for example: 0xaabbcc, 45cd32, etc.
You might use this class like this:
This call to
Hex.fromHexInput().toString()
converts the HexInput to a hex string with a leading 0x prefix, regardless of what the input format was.These are some other ways to chain the functions together:
Hex.fromHexString({ hexInput: "0x1f" }).toUint8Array()
new Hex([1, 3]).toStringWithoutPrefix()