Skip to content

Rlp

Utility functions for encoding and decoding Recursive Length Prefix structures.

Examples

import { Hex, Rlp } from 'ox'
 
const data = Rlp.fromHex([Hex.fromString('hello'), Hex.fromString('world')])
'0xcc8568656c6c6f85776f726c64'
const values = Rlp.toHex(data)
[Hex.fromString('hello'), Hex.fromString('world')]

Functions

NameDescription
Rlp.fromEncodes a Bytes.Bytes or Hex.Hex value into a Recursive-Length Prefix (RLP) value.
Rlp.fromBytesEncodes a Bytes.Bytes value into a Recursive-Length Prefix (RLP) value.
Rlp.fromHexEncodes a Hex.Hex value into a Recursive-Length Prefix (RLP) value.
Rlp.toBytesDecodes a Recursive-Length Prefix (RLP) value into a Bytes.Bytes value.
Rlp.toHexDecodes a Recursive-Length Prefix (RLP) value into a Hex.Hex value.

Errors

NameDescription
Rlp.DepthLimitExceededErrorThrown when an RLP value nests deeper than the decode depth limit.
Rlp.ListBoundaryExceededErrorThrown when RLP list items overrun the list's declared length.
Rlp.NonCanonicalErrorThrown when an RLP payload uses a non-canonical alternate encoding of a value.
Rlp.TrailingBytesErrorThrown when an RLP payload contains bytes after the decoded item.