rlp-kind
v1.1.1
Published
Bindings for Kind's implementation of RLP encoding.
Readme
rlp-kind
Node.js wrapper for the RLP Encoding library written in Kind.
We provide a proof to ensure that all encoded RLPs will be correctly decoded in the underlying implementation.
DEMO.
Install
npm install --save rlp-kindyarn add rlp-kindInstall globally if you want to use the CLI:
npm install -g rlp-kindyarn global add rlp-kindUsage
API
import * as assert from 'assert'
import * as rlp from 'rlp-kind'
const nestedList = [[], [[]], [[], [[]]]]
const encoded = rlp.encode(nestedList)
const decoded = rlp.decode(encoded)
assert.deepEqual(nestedList, decoded)encode
encode(input: InputTree): Buffer
RLP encodes a tree of data (Buffers, Strings etc) and returns a Buffer.
decode
decode(input: Input): BufferTree
Decodes an RLP encoded Buffer, String etc and returns a tree of Buffers.
The input will be converted to a buffer.
Types
type Input =
| Buffer
| string
| number
| bigint
| Uint8Array
| BN
| null
type InputTree =
| InputTree[]
| Inputtype BufferTree = Buffer | BufferTree[]CLI
$ rlp encode '[ 5 ]'
c105$ rlp decode '0xc105'
[ '05' ]