-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advice on where to implement parse_raw_transaction() #3109
Comments
Hey @coccoinomane. There's an example here using the It would definitely be handy to abstract this logic for a user though. I wouldn't be opposed to a utility method that lives in, say, |
Thanks @fselmo for the quick reply! A method in I did not know of
The If you think this makes sense, I can have a go at it. |
Ah, I suppose it isn't a dependency. Only if you install the |
I see. What if we followed the lead of ethers.js, and condensed the logic in a separate Each parsing function will just be defining a Do you reckon this solution would entail too much maintenance in the future? |
See ethereum/web3.py#3109 for details
See ethereum/web3.py#3109 for details
PS: While we decide how to proceed, I have implemented decoding of raw transactions in Command: w3 tx parse-raw-tx 0x02f86a0a75843b9aca0084412e386682520894240abf8acb28205b92d39181e2dab0b0d8ea6e5d6480c080a0a942241378fafc80670c6dde3c39ba5b1c4f992cd26fa263e7bbc253696c9035a008cf3399808cb511f0171be2ba766ea5c9d424a97dae3fb24685c440eeefc4fa Result: {
"accessList": [],
"blockHash": null,
"blockNumber": null,
"chainId": 10,
"data": "0x",
"from": "0x240AbF8ACB28205B92D39181e2Dab0B0D8eA6e5D",
"gas": 21000,
"gasPrice": null,
"maxFeePerGas": 1093548134,
"maxPriorityFeePerGas": 1000000000,
"hash": "0x8631361df65445a40fc46cff4625a2c070e618733d9ebdf31a31535276225b85",
"input": null,
"nonce": 117,
"r": "0xa942241378fafc80670c6dde3c39ba5b1c4f992cd26fa263e7bbc253696c9035",
"s": "0x08cf3399808cb511f0171be2ba766ea5c9d424a97dae3fb24685c440eeefc4fa",
"to": "0x240AbF8ACB28205B92D39181e2Dab0B0D8eA6e5D",
"transactionIndex": null,
"type": 2,
"v": null,
"value": 100
} |
I think this is simple enough and would be quite useful. It would be nice to set a default formatter on the method as a kwarg as well that could be overridden if desired but, by default, would yield a transaction that is formatted in the same way as in other places in the library. Something like: from eth_utils import apply_formatters_to_dict
from web3._utils.method_formatters import TRANSACTION_RESULT_FORMATTERS
def parse_transaction(signed_tx: HexBytes, formatter=TRANSACTION_RESULT_FORMATTERS):
# parse transaction
tx_dict = ...
return tx_dict if formatter is None else apply_formatters_to_dict(tx_dict) Depending on how the parsing is done it might need a different formatter but the concept should be similar. Thoughts there? |
Hello,
ethers.js has a handy
parseTransaction
function to decode an RLP-serialized transaction. The function understands whether it is dealing with a legacy transaction or a post-EIP1559 one, and spits out the decoded transaction object accordingly. Here's a link to its documentation & source code.Do we have a similar function in web3.py? I could not find one. Such function would be useful in serveral scenarios. One that comes to mind is in a web3.py middleware that logs all calls to
eth_sendRawTransaction
.I would be happy to have a go at developing a
parse_raw_transaction()
in web3.py, but first I would like to ask two questions that a web3.py veteran might know the answers to:Thank you,
Cocco
The text was updated successfully, but these errors were encountered: