Base58
ethers.utils.base58.decode( textData ) ⇒ Uint8Array
Return a typed Uint8Array representation of textData decoded using base-58 encoding.
base58.decode("TzMhH");
// Uint8Array [ 18, 52, 86, 120 ]
ethers.utils.base58.encode( aBytesLike ) ⇒ string
Return aBytesLike encoded as a string using the base-58 encoding.
base58.encode("0x12345678");
// 'TzMhH'
base58.encode([ 0x12, 0x34, 0x56, 0x78 ]);
// 'TzMhH'
Return a typed Uint8Array representation of textData decoded using base-64 encoding.
base64.decode("EjQ=");
// Uint8Array [ 18, 52 ]
Return aBytesLike encoded as a string using the base-64 encoding.
base64.encode("0x1234");
// 'EjQ='
base64.encode([ 0x12, 0x34 ]);
// 'EjQ='
The Recursive Length Prefix encoding is used throughout Ethereum to serialize nested structures of Arrays and data.
Encode a structured Data Object into its RLP-encoded representation.
RLP.encode("0x12345678");
// '0x8412345678'
RLP.encode([ "0x12345678" ]);
// '0xc58412345678'
RLP.encode([ new Uint8Array([ 0x12, 0x34, 0x56, 0x78 ]) ]);
// '0xc58412345678'
RLP.encode([ [ "0x42", [ "0x43" ] ], "0x12345678", [ ] ]);
// '0xcac342c1438412345678c0'
RLP.encode([ ]);
// '0xc0'
Decode an RLP-encoded aBytesLike into its structured Data Object.
All Data components will be returned as a DataHexString.
RLP.decode("0x8412345678");
// '0x12345678'
RLP.decode("0xcac342c1438412345678c0");
// [
// [
// '0x42',
// [
// '0x43'
// ]
// ],
// '0x12345678',
// []
// ]
RLP.decode("0xc0");
// []
A Data Object is a recursive structure which is used to serialize many internal structures in Ethereum. Each Data Object can either be:
- Binary Data
- An Array of Data Objects (i.e. this recursively includes Nesting)
Examples
"0x1234"
[ "0x1234", [ "0xdead", "0xbeef" ], [ ] ]
The content of this site is licensed under the Creative Commons License. Generated on April 6, 2023, 1:54am.