Skip to main content

Try it Live

Run RLP examples in the interactive playground
New to RLP? Start with Fundamentals for guided examples and encoding rules.

Type Definition

Branded data structure for RLP-encoded data with type-safe encoding and decoding.
export type BrandedRlp =
  | { type: "bytes"; value: Uint8Array }
  | { type: "list"; value: BrandedRlp[] };
RLP provides deterministic serialization for transactions, blocks, state tries, and network protocols. It encodes only structure (not types), making it space-efficient and fast.

Quick Reference

API Methods

Constructors

  • from - Create RLP data structures from bytes or nested arrays

Encoding

Decoding

Validation

  • validate - Validate RLP encoding structure and format

Utilities

Type Guards

Serialization

  • toJSON - Convert to JSON-serializable format
  • fromJSON - Convert from JSON format

Types

export type BrandedRlp =
  | { type: "bytes"; value: Uint8Array }
  | { type: "list"; value: BrandedRlp[] };
Main branded type. Union of bytes data (leaf nodes) and list data (nested arrays).BytesData: Leaf node containing raw bytes
{ type: "bytes", value: Uint8Array }
ListData: Nested array of RLP data
{ type: "list", value: BrandedRlp[] }

Specification