1

Is there any way to get a raw transaction via JSON RPC? I know how to get tx_hash from txpool, next I can get data like "from", "to", "gas", "input"... But how to get raw hex string?

I mean a raw tx like this:

0xf8ab82127c8506fc23ac0082926994b2a736980815d9c3a960e1c2a88042e4a9c9397880b844a9059cbb00000000000000000000000098aa1ad237106608b44e3a2fad6755fd5d486d3800000000000000000000000000000000000000000000000000000004a484410025a024bd7fe9b26f465ea5a06c5feb90894c60e7a5eb06a8d4bed6a729789be41660a02a9c4c909a3ab60ae76983706f1b72044572d5b9a28445771365d95ad03d1723 

1 Answer 1

2

AFAIK there's no geth api to obtain the raw transaction. However you can get all tx fields with eth_getTransactionByHash and construct the raw transaction with them.

2
  • How can I construct raw_tx with fields from eth_getTransactionByHash? As I understand, I need to have private_key to do it. Is it possible to create raw_tx without private key?
    – Max Block
    Jun 1, 2020 at 6:05
  • @MaxBlock You can use ethereumjs-tx and construct a transaction passing the fields returned by getTransactionByHash (including the signature v, r, s). Then use .serialize() to obtain the raw transaction.
    – Ismael
    Jun 1, 2020 at 7:59

Your Answer

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

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