ethereumjs-monorepo
ethereumjs-monorepo copied to clipboard
rlp decode example does not work
Running rlp decode 0xc88363617483646f67 returns ["636174","646f67"] for me not ["cat","dog"].
What is this format and how do I return the actual string?
Ok, so this seems to be a simple hex encoding. But shouldn't the function return the actual string as described in the example?
hey @SharifElfouly thanks for reporting, you are indeed right we are just returning the hex strings in the cli interface.
to return the string representation, I replaced this line:
https://github.com/ethereumjs/ethereumjs-monorepo/blob/7a3549aed58836adfaf03bcb64bac4384096afc0/packages/rlp/bin/rlp#L50
with
return new TextDecoder().decode(ba)
Which works:
❯ bin/rlp decode 0xc88363617483646f67
["cat","dog"]
However then we can't decode simple numbers, like this:
"mediumint1": {
"in": 128,
"out": "0x8180"
},
❯ bin/rlp encode 128
0x8180
❯ bin/rlp decode 0x8180
"�"
so I'm not sure what's the best approach here. @paulmillr do you have any thoughts?
Outdated, will close.