Encoder
in package
Encoder of RLP format capable of working with both binary and hex outputs. Internally works on binary.
Tags
Table of Contents
Methods
- encodeBin() : string
- Converts data to RLP Accepts array (recursively - can contain sub-arrays, sub-sub-arrays, etc.) of 0x-hex strings, ints, Hash (and children) types.
- encodeHex() : string
- Converts data to RLP Accepts array (recursively - can contain sub-arrays, sub-sub-arrays, etc.) of 0x-hex strings, ints, Hash (and children) types.
- encodeArray() : string
- encodeBinaryVal() : string
- encodeHash() : string
- encodeInt() : string
- encodeLength() : string
- encodeOOGmp() : string
- encodeString() : string
Methods
encodeBin()
Converts data to RLP Accepts array (recursively - can contain sub-arrays, sub-sub-arrays, etc.) of 0x-hex strings, ints, Hash (and children) types.
public
static encodeBin(array<string|int, mixed> $input) : string
All non-hex-strings will be converted to hex strings as actual strings (ie. "foo" will be 0x666f6f - 102, 111, 111). Entire input will NOT be wrapped with array, as some might expect. If you require this (ie. legacy transactions), wrap the input on caller side
Parameters
- $input : array<string|int, mixed>
-
data to be encoded
Return values
string —binary blob of encoded data
encodeHex()
Converts data to RLP Accepts array (recursively - can contain sub-arrays, sub-sub-arrays, etc.) of 0x-hex strings, ints, Hash (and children) types.
public
static encodeHex(array<string|int, mixed> $input) : string
All non-hex-strings will be converted to hex strings as actual strings (ie. "foo" will be 0x666f6f - 102, 111, 111). Entire input will NOT be wrapped with array, as some might expect. If you require this (ie. legacy transactions), wrap the input on caller side
Parameters
- $input : array<string|int, mixed>
-
data to be encoded
Return values
string —hex representation of encoded data
encodeArray()
private
static encodeArray(array<string|int, mixed> $input) : string
Parameters
- $input : array<string|int, mixed>
Return values
stringencodeBinaryVal()
private
static encodeBinaryVal(string $input) : string
Parameters
- $input : string
Return values
stringencodeHash()
private
static encodeHash(Hash $input) : string
Parameters
- $input : Hash
Return values
stringencodeInt()
private
static encodeInt(int $input) : string
Parameters
- $input : int
Return values
stringencodeLength()
private
static encodeLength(int $length, int $base) : string
Parameters
- $length : int
- $base : int
Return values
stringencodeOOGmp()
private
static encodeOOGmp(OOGmp $input) : string
Parameters
- $input : OOGmp
Return values
stringencodeString()
private
static encodeString(string $input) : string
Parameters
- $input : string