@zoltu/rlp-encoder
TypeScript icon, indicating that this package has built-in type declarations

2.0.6 • Public • Published

RLP Encoder

A 0-depnedency simple RLP encoder that only encodes Uint8Arrays and arrays of them (including nested). It is up to the user to appropriately convert their numbers, bigints, strings, etc. into Uint8Arrays since the RLP specification does not prescribe how such things are encoded prior to being RLP encoded.

Usage

npm install @zoltu/rlp-encoder
const input = [
	[new Uint8Array([0x6b, 0x65, 0x79, 0x31]), new Uint8Array([0x76, 0x61, 0x6c, 0x31])],
	[new Uint8Array([0x6b, 0x65, 0x79, 0x32]), new Uint8Array([0x76, 0x61, 0x6c, 0x32])],
	[new Uint8Array([0x6b, 0x65, 0x79, 0x33]), new Uint8Array([0x76, 0x61, 0x6c, 0x33])],
	[new Uint8Array([0x6b, 0x65, 0x79, 0x34]), new Uint8Array([0x76, 0x61, 0x6c, 0x34])],
]
const actual = rlpEncode(input) // [0xec, 0xca, 0x84, 0x6b, 0x65, 0x79, 0x31, 0x84, 0x76, 0x61, 0x6c, 0x31, 0xca, 0x84, 0x6b, 0x65, 0x79, 0x32, 0x84, 0x76, 0x61, 0x6c, 0x32, 0xca, 0x84, 0x6b, 0x65, 0x79, 0x33, 0x84, 0x76, 0x61, 0x6c, 0x33, 0xca, 0x84, 0x6b, 0x65, 0x79, 0x34, 0x84, 0x76, 0x61, 0x6c, 0x34] as Uint8Array

Readme

Keywords

none

Package Sidebar

Install

npm i @zoltu/rlp-encoder

Weekly Downloads

11

Version

2.0.6

License

Unlicense

Unpacked Size

76.6 kB

Total Files

15

Last publish

Collaborators

  • micah.zoltu