| title | Hexadecimal encoding |
|---|
Many of Ethereum and Swarm APIs require inputs or output values to be encoded as an hexadecimal string prefixed with 0x, therefore many of Erebos APIs also have this requirement.
The @erebos/hex package is used by other Erebos packages to ease the interactions with some APIs by providing an abstraction on top of it.
The Hex class is a container for the prefixed hexadecimal string, exposed in its value property, but also handles strings, objects and buffers as input and output values in order to simplify application-level interactions.
npm install @erebos/heximport { Hex } from '@erebos/hex'
const fromString = Hex.from('Hello world!')
fromString.value // '0x48656c6c6f20776f726c6421'
const fromHex = Hex.from('0x48656c6c6f20776f726c6421')
fromHex.toString() // 'Hello world!'enum HexValue {}
type hexValue = HexValue & stringtype hexInput = hexValue | string | Record<string, any> | Buffer | Array<number>Arguments
value: any
Returns boolean
Arguments
value: hexInput | Hex
Arguments
value: hexInput | Hex
Returns Hex
Returns hexValue
Arguments
other: hexInput | Hex
Returns boolean
Returns Buffer
Returns Array<number>
Returns Record<string, any>
Returns string