Skip to content

fromRlp

Decodes a Recursive-Length Prefix (RLP) value into a decoded hex value or byte array.

Import

import { fromRlp } from 'viem'

Usage

import { fromRlp } from 'viem'
 
fromRlp('0x850123456789', 'hex')
// "0x123456789"
 
fromRlp('0xc67f7f838081e8', 'hex')
// ['0x7f', '0x7f', '0x8081e8']
 
fromRlp('0x89010203040506070809', 'bytes')
//  Uint8Array [1, 2, 3, 4, 5, 6, 7, 8, 9]
 
fromRlp(new Uint8Array ([133, 1, 35, 69, 103, 137]), 'hex')
// "0x123456789"

Returns

Hex | ByteArray

The hex value or byte array.

Parameters

value

  • Type: Hex | ByteArray

The RLP value to decode.

to

  • Type: "bytes" | "hex"

The output type.