# Rlp

Utility functions for encoding and decoding [Recursive Length Prefix](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/) structures.

## Examples

```ts twoslash
import { Hex, Rlp } from 'ox'

const data = Rlp.fromHex([
  Hex.fromString('hello'),
  Hex.fromString('world')
])
// @log: '0xcc8568656c6c6f85776f726c64'

const values = Rlp.toHex(data)
// @log: [Hex.fromString('hello'), Hex.fromString('world')]
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Rlp.from`](/api/Rlp/from) | Encodes a [`Bytes.Bytes`](/api/Bytes/types#bytes) or [`Hex.Hex`](/api/Hex/types#hex) value into a Recursive-Length Prefix (RLP) value. |
| [`Rlp.fromBytes`](/api/Rlp/fromBytes) | Encodes a [`Bytes.Bytes`](/api/Bytes/types#bytes) value into a Recursive-Length Prefix (RLP) value. |
| [`Rlp.fromHex`](/api/Rlp/fromHex) | Encodes a [`Hex.Hex`](/api/Hex/types#hex) value into a Recursive-Length Prefix (RLP) value. |
| [`Rlp.toBytes`](/api/Rlp/toBytes) | Decodes a Recursive-Length Prefix (RLP) value into a [`Bytes.Bytes`](/api/Bytes/types#bytes) value. |
| [`Rlp.toHex`](/api/Rlp/toHex) | Decodes a Recursive-Length Prefix (RLP) value into a [`Hex.Hex`](/api/Hex/types#hex) value. |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Rlp.DepthLimitExceededError`](/api/Rlp/errors#rlpdepthlimitexceedederror) | Thrown when an RLP value nests deeper than the decode depth limit. |
| [`Rlp.ListBoundaryExceededError`](/api/Rlp/errors#rlplistboundaryexceedederror) | Thrown when RLP list items overrun the list's declared length. |
| [`Rlp.TrailingBytesError`](/api/Rlp/errors#rlptrailingbyteserror) | Thrown when an RLP payload contains bytes after the decoded item. |
