Determine if two Hex instances are equal by comparing their underlying byte data.
The Hex instance to compare to.
true if the Hex instances are equal, false if not.
Static
fromConverts an instance of HexInput, which can be a string or a Uint8Array, into a Hex instance. This function is useful for transforming hexadecimal representations into a structured Hex object for further manipulation.
A HexInput which can be a string or Uint8Array.
A Hex instance created from the provided hexInput.
Static
fromStatic
isCheck if the provided string is a valid hexadecimal representation.
A hex string representing byte data.
An object containing:
NOTE: Do not use this class when working with account addresses; use AccountAddress instead. When accepting hex data as input to a function, prefer to accept HexInput and
A helper class for working with hex data. Hex data, when represented as a string, generally looks like this, for example: 0xaabbcc, 45cd32, etc.
then use the static helper methods of this class to convert it into the desired format. This enables the greatest flexibility for the developer.
Example usage:
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.Other ways to chain the functions together:
Hex.fromHexString({ hexInput: "0x1f" }).toUint8Array()
new Hex([1, 3]).toStringWithoutPrefix()