You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There should be an easy way to take a transaction directly as a JSON-RPC dict and put it into an object that can encode() and decode() the transaction. This would behave much like the TypedTransaction class does for typed transactions in eth-account - and in fact this class can probably carry a lot of the heavy load here - but it also needs to clean up certain fields based on the type in order for it to even be plugged into the TypedTransaction class.
I'm thinking something like:
>>>fromweb3.utilsimportWeb3Transaction>>># from dict>>>txn=Web3Transaction.from_dict(w3.eth.get_transaction("0x..."))
>>>txn.encode().hex()
02ed01808504a817c8008504a817c800830186a09400000000000000000000000000000000000000008080c0808080...
>>># from bytes>>>txn=Web3Transaction.from_bytes(b'\x02\xed\x01\x80\x85\x04\xa8\x17\xc8\x00\x85\x04\xa8\x17\xc8\x00\x83\x01\x86\xa0\x94\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x80\xc0\x80\x80\x80')
>>>txn.as_dict()
{
"chainId": 1,
"maxFeePerGas": 20000000000,
"maxPriorityFeePerGas": 20000000000,
"nonce": 0,
...
}
>>># fields accessible as properties>>>txn.max_fee_per_gas20000000000
Or, maybe it's a HexBytes as the result of encode(). Either way, I think the utility here is fairly clear. Take a transaction straight from a result, put it into a utility class, and be able to manipulate and have useful methods available on the transaction.
The content you are editing has changed. Please copy your edits and refresh the page.
What feature should we add?
There should be an easy way to take a transaction directly as a JSON-RPC dict and put it into an object that can
encode()
anddecode()
the transaction. This would behave much like theTypedTransaction
class does for typed transactions in eth-account - and in fact this class can probably carry a lot of the heavy load here - but it also needs to clean up certain fields based on the type in order for it to even be plugged into theTypedTransaction
class.I'm thinking something like:
Or, maybe it's a
HexBytes
as the result ofencode()
. Either way, I think the utility here is fairly clear. Take a transaction straight from a result, put it into a utility class, and be able to manipulate and have useful methods available on the transaction.Tasks
The text was updated successfully, but these errors were encountered: