1

I'm trying to understand how to create Ethereum transaction from scratch but I'm not sure what am I supposed to sign.

Should I sign the hashed rlp encoded transaction or just the rlp encoded raw transaction?

  1. Rlp encoded tx: f83a1854a817c80821458a83730393937393730433531383132646333413031304337643031623530653064313764633739433885174876e8080
  2. Rlp encoded hashed tx: Hash(f83a1854a817c80821458a83730393937393730433531383132646333413031304337643031623530653064313764633739433885174876e8080)

Thanks!

1 Answer 1

1

you are supposed to sign the transaction hash. the hash is 32 bytes.

the hash is returned by Hash() function of Ethereum API and it is a complex function which will depend on block number. the block number will tell what kind of fork is Ethereum currently on (London,Berlin, EIP155, etc). Depending on Ethereum fork, the process of generating these 32 bytes (the hash) you need to sign will be different, and of course it will be rlp-encoded internally (the order/amount of fields varies depending on the fork).

the signature must be produced by ECDSA algorithm and comply with its format (as the standard specifies). these are the R/S/V fields which are set by the API after your transaction is signed (by common libraries we all use)

all of this stuff is already done by the libraries so you just have to call the appropriate functions to avoid reinventing the wheel

1
  • Thanks for the answer! I know I could use ethers or web3.js. I just wanted to know how exactly it works.
    – Kuly14
    Commented Dec 21, 2022 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.