Ref

Ethereum使用RLP来序列化结构数据

encoding method used to serialize objects in Ethereum. The only purpose of RLP is to encode structure; encoding specific atomic data types (eg. strings, ints, floats) is left up to higher-order protocols; in Ethereum integers must be represented in big endian binary form with no leading zeroes (thus making the integer value zero be equivalent to the empty byte array).

If one wishes to use RLP to encode a dictionary, the two suggested canonical forms are to either use [[k1,v1],[k2,v2]...] with keys in lexicographic order or to use the higher-level Patricial Tree encoding as Ethereum does.

定义

RLP的输入是一个item,item的定义是

编码

字符串:

数组/列表:

识别

经过上面的编码后,很容易解码任意数据结构。判断第一字节即可: