Skip to main content
@tevm/voltaire
@tevm/voltaire / index / BrandedRlp

BrandedRlp

Variables

BrandedRlp

const BrandedRlp: object
Defined in: src/primitives/Rlp/internal-index.ts:65

Type Declaration

decode()
decode: (bytes, stream?) => Decoded
Decodes RLP-encoded bytes
Parameters
bytes
Uint8Array<ArrayBufferLike> RLP-encoded data
stream?
boolean = false If true, allows extra data after decoded value. If false, expects exact match
Returns
Decoded Decoded RLP data with remainder
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If input is too short, invalid, or has unexpected remainder (when stream=false)
Example
decodeArray()
decodeArray: (data) => any[]
Decodes RLP-encoded bytes to an array
Parameters
data
Uint8Array<ArrayBufferLike> RLP-encoded data
Returns
any[] Decoded array
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If decoding fails
Example
decodeBatch()
decodeBatch: (data) => any[][]
Decodes multiple RLP-encoded items
Parameters
data
Uint8Array<ArrayBufferLike>[] Array of RLP-encoded data
Returns
any[][] Array of decoded results
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If decoding fails for any item
Example
decodeObject()
decodeObject: (data) => Record<string, any>
Decodes RLP-encoded bytes to an object with known keys
Parameters
data
Uint8Array<ArrayBufferLike> RLP-encoded data
Returns
Record<string, any> Decoded object
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If decoding fails or data format is invalid
Example
encode()
encode: (data) => Uint8Array<ArrayBufferLike>
Encodes data to RLP format
Parameters
data
Encodable Data to encode (Uint8Array, RlpData, or array)
Returns
Uint8Array<ArrayBufferLike> RLP-encoded bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If data type is invalid or encoding fails
Example
encodeArray()
encodeArray: (items) => Uint8Array<ArrayBufferLike>
Encodes an array of values to RLP format
Parameters
items
Encodable[] Array of values to encode
Returns
Uint8Array<ArrayBufferLike> RLP-encoded bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails
Example
encodeBatch()
encodeBatch: (items) => Uint8Array<ArrayBufferLike>[]
Encodes multiple items efficiently
Parameters
items
Encodable[][] Array of items to encode
Returns
Uint8Array<ArrayBufferLike>[] Array of RLP-encoded results
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails for any item
Example
encodeBytes()
encodeBytes: (bytes) => Uint8Array<ArrayBufferLike>
Encodes a byte array according to RLP string rules
Parameters
bytes
Uint8Array<ArrayBufferLike> Byte array to encode
Returns
Uint8Array<ArrayBufferLike> RLP-encoded bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails
Example
encodeList()
encodeList: (items) => Uint8Array<ArrayBufferLike>
Encodes a list of RLP-encodable items
Parameters
items
(any[] | Uint8Array<ArrayBufferLike> | BrandedRlp)[] Array of items to encode
Returns
Uint8Array<ArrayBufferLike> RLP-encoded list
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails
Example
encodeObject()
encodeObject: (obj) => Uint8Array<ArrayBufferLike>
Encodes an object (key-value pairs) to RLP format Converts object to array of [key, value] pairs and encodes
Parameters
obj
Record<string, Encodable> Object to encode
Returns
Uint8Array<ArrayBufferLike> RLP-encoded bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails
Example
encodeVariadic()
encodeVariadic: (…items) => Uint8Array<ArrayBufferLike>
Encodes a variadic list of items to RLP format
Parameters
items
Encodable[] Items to encode
Returns
Uint8Array<ArrayBufferLike> RLP-encoded bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If encoding fails
Example
equals()
equals: (data, other) => boolean
Check if two RLP Data structures are equal
Parameters
data
BrandedRlp First RLP data structure
other
BrandedRlp Second RLP data structure
Returns
boolean True if structures are deeply equal
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
flatten()
flatten: (data) => BrandedRlp & object[]
Flatten nested list Data into array of bytes Data (depth-first)
Parameters
data
BrandedRlp RLP data structure to flatten
Returns
BrandedRlp & object[] Array of bytes data (all nested lists flattened)
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
from()
from: (value) => BrandedRlp
Create RLP data from various inputs
Parameters
value
Uint8Array (bytes), RlpData, or array (list) Uint8Array<ArrayBufferLike> | BrandedRlp | BrandedRlp[]
Returns
BrandedRlp RLP data structure
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If input type is invalid
Example
fromJSON()
fromJSON: (json) => BrandedRlp
Convert JSON representation back to RLP Data
Parameters
json
unknown JSON object from toJSON
Returns
BrandedRlp RLP data structure
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If JSON format is invalid or type is unrecognized
Example
getEncodedLength()
getEncodedLength: (data) => number
Get the total byte length of RLP-encoded data without actually encoding
Parameters
data
Data to measure any[] | Uint8Array<ArrayBufferLike> | BrandedRlp
Returns
number Length in bytes after RLP encoding
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If data type is invalid
Example
getLength()
getLength: (data) => number
Gets the total length of an RLP item (prefix + payload)
Parameters
data
Uint8Array<ArrayBufferLike> RLP-encoded data
Returns
number Total length in bytes
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If data is empty, too short, or has invalid prefix
Example
isBytesData()
isBytesData: (value) => boolean
Check if value is RLP bytes data
Parameters
value
unknown Value to check
Returns
boolean True if value is RLP bytes data structure
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
isCanonical()
isCanonical: (bytes, depth?) => boolean
Validates if RLP encoding is canonical Canonical encoding rules:
  • Integers must use minimum bytes (no leading zeros)
  • Strings/bytes must use shortest length prefix
  • Single byte < 0x80 must not be encoded as string
  • Length prefix must use minimum bytes
Parameters
bytes
Uint8Array<ArrayBufferLike> RLP-encoded data
depth?
number = 0 Current recursion depth (internal)
Returns
boolean True if encoding is canonical
See
Since
0.0.0
Throws
Example
isData()
isData: (value) => value is BrandedRlp
Check if value is RLP Data structure
Parameters
value
unknown Value to check
Returns
value is BrandedRlp True if value is valid RLP data structure
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
isList()
isList: (data) => boolean
Checks if RLP-encoded data represents a list
Parameters
data
Uint8Array<ArrayBufferLike> RLP-encoded data
Returns
boolean True if data encodes a list
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If data is empty
Example
isListData()
isListData: (value) => boolean
Check if value is RLP list data
Parameters
value
unknown Value to check
Returns
boolean True if value is RLP list data structure
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
isString()
isString: (data) => boolean
Checks if RLP-encoded data represents a string (byte array)
Parameters
data
Uint8Array<ArrayBufferLike> RLP-encoded data
Returns
boolean True if data encodes a string
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
If data is empty
Example
toJSON()
toJSON: (data) => unknown
Convert RLP Data to human-readable JSON format
Parameters
data
BrandedRlp RLP data structure
Returns
unknown JSON-serializable representation
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
toRaw()
toRaw: (data) => any[] | Uint8Array<ArrayBufferLike>
Converts RLP Data structure to raw JavaScript values (Uint8Array or nested arrays)
Parameters
data
BrandedRlp RLP data structure to convert
Returns
any[] | Uint8Array<ArrayBufferLike> Raw value (Uint8Array for bytes, array for list)
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example
validate()
validate: (data) => boolean
Validates if data is valid RLP encoding
Parameters
data
Uint8Array<ArrayBufferLike> Data to validate
Returns
boolean True if valid RLP encoding
See
https://voltaire.tevm.sh/primitives/rlp for RLP documentation
Since
0.0.0
Throws
Example

Functions

decode()

decode(bytes, stream?): Decoded
Defined in: src/primitives/Rlp/decode.js:75 Decodes RLP-encoded bytes

Parameters

bytes
Uint8Array<ArrayBufferLike> RLP-encoded data
stream?
boolean = false If true, allows extra data after decoded value. If false, expects exact match

Returns

Decoded Decoded RLP data with remainder

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If input is too short, invalid, or has unexpected remainder (when stream=false)

Example


decodeArray()

decodeArray(data): any[]
Defined in: src/primitives/Rlp/decodeArray.js:23 Decodes RLP-encoded bytes to an array

Parameters

data
Uint8Array<ArrayBufferLike> RLP-encoded data

Returns

any[] Decoded array

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If decoding fails

Example


decodeBatch()

decodeBatch(data): any[][]
Defined in: src/primitives/Rlp/decodeBatch.js:23 Decodes multiple RLP-encoded items

Parameters

data
Uint8Array<ArrayBufferLike>[] Array of RLP-encoded data

Returns

any[][] Array of decoded results

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If decoding fails for any item

Example


decodeObject()

decodeObject(data): Record<string, any>
Defined in: src/primitives/Rlp/decodeObject.js:20 Decodes RLP-encoded bytes to an object with known keys

Parameters

data
Uint8Array<ArrayBufferLike> RLP-encoded data

Returns

Record<string, any> Decoded object

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If decoding fails or data format is invalid

Example


encode()

encode(data): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encode.js:47 Encodes data to RLP format

Parameters

data
Encodable Data to encode (Uint8Array, RlpData, or array)

Returns

Uint8Array<ArrayBufferLike> RLP-encoded bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If data type is invalid or encoding fails

Example


encodeArray()

encodeArray(items): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encodeArray.js:25 Encodes an array of values to RLP format

Parameters

items
Encodable[] Array of values to encode

Returns

Uint8Array<ArrayBufferLike> RLP-encoded bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails

Example


encodeBatch()

encodeBatch(items): Uint8Array<ArrayBufferLike>[]
Defined in: src/primitives/Rlp/encodeBatch.js:26 Encodes multiple items efficiently

Parameters

items
Encodable[][] Array of items to encode

Returns

Uint8Array<ArrayBufferLike>[] Array of RLP-encoded results

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails for any item

Example


encodeBytes()

encodeBytes(bytes): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encodeBytes.js:30 Encodes a byte array according to RLP string rules

Parameters

bytes
Uint8Array<ArrayBufferLike> Byte array to encode

Returns

Uint8Array<ArrayBufferLike> RLP-encoded bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails

Example


encodeList()

encodeList(items): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encodeList.js:29 Encodes a list of RLP-encodable items

Parameters

items
(any[] | Uint8Array<ArrayBufferLike> | BrandedRlp)[] Array of items to encode

Returns

Uint8Array<ArrayBufferLike> RLP-encoded list

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails

Example


encodeObject()

encodeObject(obj): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encodeObject.js:26 Encodes an object (key-value pairs) to RLP format Converts object to array of [key, value] pairs and encodes

Parameters

obj
Record<string, Encodable> Object to encode

Returns

Uint8Array<ArrayBufferLike> RLP-encoded bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails

Example


encodeVariadic()

encodeVariadic(…items): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/encodeVariadic.js:25 Encodes a variadic list of items to RLP format

Parameters

items
Encodable[] Items to encode

Returns

Uint8Array<ArrayBufferLike> RLP-encoded bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If encoding fails

Example


equals()

equals(data, other): boolean
Defined in: src/primitives/Rlp/equals.js:19 Check if two RLP Data structures are equal

Parameters

data
BrandedRlp First RLP data structure
other
BrandedRlp Second RLP data structure

Returns

boolean True if structures are deeply equal

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


flatten()

flatten(data): BrandedRlp & object[]
Defined in: src/primitives/Rlp/flatten.js:29 Flatten nested list Data into array of bytes Data (depth-first)

Parameters

data
BrandedRlp RLP data structure to flatten

Returns

BrandedRlp & object[] Array of bytes data (all nested lists flattened)

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


from()

from(value): BrandedRlp
Defined in: src/primitives/Rlp/from.js:20 Create RLP data from various inputs

Parameters

value
Uint8Array (bytes), RlpData, or array (list) Uint8Array<ArrayBufferLike> | BrandedRlp | BrandedRlp[]

Returns

BrandedRlp RLP data structure

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If input type is invalid

Example


fromJSON()

fromJSON(json): BrandedRlp
Defined in: src/primitives/Rlp/fromJSON.js:19 Convert JSON representation back to RLP Data

Parameters

json
unknown JSON object from toJSON

Returns

BrandedRlp RLP data structure

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If JSON format is invalid or type is unrecognized

Example


getEncodedLength()

getEncodedLength(data): number
Defined in: src/primitives/Rlp/getEncodedLength.js:21 Get the total byte length of RLP-encoded data without actually encoding

Parameters

data
Data to measure any[] | Uint8Array<ArrayBufferLike> | BrandedRlp

Returns

number Length in bytes after RLP encoding

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If data type is invalid

Example


getLength()

getLength(data): number
Defined in: src/primitives/Rlp/getLength.js:20 Gets the total length of an RLP item (prefix + payload)

Parameters

data
Uint8Array<ArrayBufferLike> RLP-encoded data

Returns

number Total length in bytes

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If data is empty, too short, or has invalid prefix

Example


isBytesData()

isBytesData(value): boolean
Defined in: src/primitives/Rlp/isBytesData.js:20 Check if value is RLP bytes data

Parameters

value
unknown Value to check

Returns

boolean True if value is RLP bytes data structure

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


isCanonical()

isCanonical(bytes, depth?): boolean
Defined in: src/primitives/Rlp/isCanonical.js:34 Validates if RLP encoding is canonical Canonical encoding rules:
  • Integers must use minimum bytes (no leading zeros)
  • Strings/bytes must use shortest length prefix
  • Single byte < 0x80 must not be encoded as string
  • Length prefix must use minimum bytes

Parameters

bytes
Uint8Array<ArrayBufferLike> RLP-encoded data
depth?
number = 0 Current recursion depth (internal)

Returns

boolean True if encoding is canonical

See

Since

0.0.0

Throws

Example


isData()

isData(value): value is BrandedRlp
Defined in: src/primitives/Rlp/isData.js:20 Check if value is RLP Data structure

Parameters

value
unknown Value to check

Returns

value is BrandedRlp True if value is valid RLP data structure

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


isList()

isList(data): boolean
Defined in: src/primitives/Rlp/isList.js:23 Checks if RLP-encoded data represents a list

Parameters

data
Uint8Array<ArrayBufferLike> RLP-encoded data

Returns

boolean True if data encodes a list

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If data is empty

Example


isListData()

isListData(value): boolean
Defined in: src/primitives/Rlp/isListData.js:20 Check if value is RLP list data

Parameters

value
unknown Value to check

Returns

boolean True if value is RLP list data structure

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


isString()

isString(data): boolean
Defined in: src/primitives/Rlp/isString.js:23 Checks if RLP-encoded data represents a string (byte array)

Parameters

data
Uint8Array<ArrayBufferLike> RLP-encoded data

Returns

boolean True if data encodes a string

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

If data is empty

Example


toJSON()

toJSON(data): unknown
Defined in: src/primitives/Rlp/toJSON.js:17 Convert RLP Data to human-readable JSON format

Parameters

data
BrandedRlp RLP data structure

Returns

unknown JSON-serializable representation

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


toRaw()

toRaw(data): any[] | Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Rlp/toRaw.js:27 Converts RLP Data structure to raw JavaScript values (Uint8Array or nested arrays)

Parameters

data
BrandedRlp RLP data structure to convert

Returns

any[] | Uint8Array<ArrayBufferLike> Raw value (Uint8Array for bytes, array for list)

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example


validate()

validate(data): boolean
Defined in: src/primitives/Rlp/validate.js:21 Validates if data is valid RLP encoding

Parameters

data
Uint8Array<ArrayBufferLike> Data to validate

Returns

boolean True if valid RLP encoding

See

https://voltaire.tevm.sh/primitives/rlp for RLP documentation

Since

0.0.0

Throws

Example

References

Encodable

Re-exports Encodable

Error

Re-exports Error

ErrorType

Re-exports ErrorType

MAX_DEPTH

Re-exports MAX_DEPTH

RlpError

Re-exports RlpError