Skip to content

RLP Serializer & Deserializer

Afri edited this page Oct 31, 2022 · 1 revision

Serialize and deserialize Ethereum recursive-length prefix data (RLP).

Eth::Util.bin_to_hex Eth::Rlp.encode ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]
# => "f78b48656c6c6f2c20426f6221aa307864343936623233643631663838613863373735386663613735363064636661633762336230316639"
Eth::Rlp.decode "f78b48656c6c6f2c20426f6221aa307864343936623233643631663838613863373735386663613735363064636661633762336230316639"
# => ["Hello, Bob!", "0xd496b23d61f88a8c7758fca7560dcfac7b3b01f9"]

Or ;-)

Eth::Rlp.decode "c7c0c1c0c3c0c1c0"
# => [[], [[]], [[], [[]]]]
Clone this wiki locally