mhw0 / libethc

Open-source Ethereum C library
https://mhw0.github.io/libethc/
MIT License
46 stars 8 forks source link

example: add EIP-1559 tx example #42

Closed zzzzzzch closed 1 month ago

zzzzzzch commented 1 month ago

hi it is a great lib. I found that EIP-1559 transaction is absent in example dir, so the code was added for this purpose. Most of the variables and values in this example are copied from legacy-transaction.c.

But I'm not sure about one thing: when access_list is empty, do I need to add it when constructing RLP? After my test, it seems that it can be added or not (I temporarily commented this in the example)

mhw0 commented 1 month ago

hi it is a great lib. I found that EIP-1559 transaction is absent in example dir, so the code was added for this purpose. Most of the variables and values in this example are copied from legacy-transaction.c.

Hello, thank you for the PR.

But I'm not sure about one thing: when access_list is empty, do I need to add it when constructing RLP? After my test, it seems that it can be added or not (I temporarily commented this in the example)

ok(eth_rlp_array(&rlp0));
  // ok(eth_rlp_hex(&rlp0, &accees_list, NULL)); // empty for access_list
ok(eth_rlp_array_end(&rlp0));

you're already declaring empty array here before encoding empty hex (0x)

these are basically the same thing:

ok(eth_rlp_array(&rlp0));
ok(eth_rlp_array_end(&rlp0));
// and 
ok(eth_rlp_hex(&rlp0, &accees_list, NULL)); // empty for access_list
mhw0 commented 1 month ago

Hopefully you tested the code, merging it!