0

I have tried using the eth_account library but it doesnt work on newer transactions (type 0x02 transactions). What is a method of retrieval that would work on those transactions?

from eth_account._utils.signing import extract_chain_id, to_standard_v, serializable_unsigned_transaction_from_dict 
from eth_account._utils.legacy_transactions import ALLOWED_TRANSACTION_KEYS

s = web3.eth.account._keys.Signature(vrs=( to_standard_v(extract_chain_id(tx.v)[1]), web3.toInt(tx.r), web3.toInt(tx.s) ))

tt = {k:tx[k] for k in ALLOWED_TRANSACTION_KEYS - {'chainId', 'data'}} tt['data']=tx.input tt['chainId']=extract_chain_id(tx.v)[0]

from eth_account._utils.legacy_transactions import serializable_unsigned_transaction_from_dict ut = serializable_unsigned_transaction_from_dict(tt)

print('public key') s.recover_public_key_from_msg_hash(ut.hash())

ChuanC
  • 1

1 Answers1

0

Take a look to this previously asked questions, you should find the answer there:

ethers.js Recover public key from contract deployment via v,r,s values

How to recover sender's public key from a transaction json object with Ethers (Updated answers)

Alexander Herranz
  • 1,858
  • 2
  • 17
  • 35
  • those solutions uses Js. Is there currently any method for python? – ChuanC Feb 20 '23 at 17:15
  • Yes sure, but with different library. This is for you: https://web3py.readthedocs.io/en/v5/

    You can also check it out here: https://ethereum.org/en/developers/docs/programming-languages/python/

    – Alexander Herranz Feb 20 '23 at 17:19