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())
1

1 Answer 1

1

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)

2

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.