I want to RLP-encode a(n unsigned) transaction. Some fields of the transaction can be empty/null/zero. I want to know how they are encoded, though.
Let's assume the following transaction fields:
signer_nonce = 0 gas_price = 0 gas_limit = 21000 destination = nil amount = 0 payload = nil
Nonce, gas price, limit, and amount are easily encoded using any RLP-encoder and a value of
0x00 is perfectly fine.
But how do I encode empty fields if I don't have any data or any recipient address?
Eth::Util.bin_to_hex(RLP.encode(nil)) /home/user/.gem/ruby/3.0.0/gems/rlp-0.7.3/lib/rlp/sedes.rb:31:in `infer': Did not find sedes handling type NilClass (TypeError) from /home/user/.gem/ruby/3.0.0/gems/rlp-0.7.3/lib/rlp/encode.rb:51:in `encode' from (irb):14:in `<main>' from /usr/lib/ruby/gems/3.0.0/gems/irb-1.3.6/exe/irb:11:in `<top (required)>' from /bin/irb:23:in `load' from /bin/irb:23:in `<main>'
I cannot set the address to
0x00 as this would be a valid address afaik. Should I use the empty string byte
0x80? How would I distinguish and empty string from the zero byte
Eth::Util.bin_to_hex(RLP.encode("")) => "80" Eth::Util.bin_to_hex(RLP.encode(0)) => "80"
How to encode empty transaction fields such as empty data or no recipient address?