Class Rlp
Utility class for Recursive Length Prefix (RLP) encoding and decoding, used for serializing data in EVM-compatible transactions.
Inherited Members
Namespace: Hiero
Assembly: Hiero.dll
Syntax
public static class Rlp
Methods
| Edit this page View SourceDecode(byte[])
Decodes an RLP-encoded byte array into its constituent data items.
Declaration
public static object[] Decode(byte[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | data | The RLP-encoded byte array to decode. |
Returns
| Type | Description |
|---|---|
| object[] | An array of decoded objects, where each element is either a byte array or a nested array of objects. |
Exceptions
| Type | Condition |
|---|---|
| FormatException | If the data is not valid RLP: an item's declared length runs past the end of the data, or a length prefix is too long to describe data held in memory. |
Encode(params object?[])
RLP-encodes one or more data items into a byte array. A single
argument is encoded as that item alone; two or more arguments are
encoded as an RLP list. Calling with no arguments produces an
empty list (0xC0), and a null array produces
0x80.
Declaration
public static byte[] Encode(params object?[] data)
Parameters
| Type | Name | Description |
|---|---|---|
| object[] | data | The data items to encode: |
Returns
| Type | Description |
|---|---|
| byte[] | The RLP-encoded byte array. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | If a data item is of an unsupported type. |
| ArgumentOutOfRangeException | If a numeric data item is negative. |