-
-
Save notcod/5eb80bcf59bbb9a7333a1595758ff07a to your computer and use it in GitHub Desktop.
Python script for getting ethereum public key from transaction id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import web3 | |
| w3 = web3.Web3(web3.HTTPProvider('https://geth.golem.network:55555')) | |
| tx = w3.eth.getTransaction('0x00ee93fd1e6fdbdf841b4458a078210449dce89525502c965fd3534ba397e2e3') | |
| tx.hash | |
| from eth_account._utils.signing import extract_chain_id, to_standard_v | |
| s = w3.eth.account._keys.Signature(vrs=( | |
| to_standard_v(extract_chain_id(tx.v)[1]), | |
| w3.toInt(tx.r), | |
| w3.toInt(tx.s) | |
| )) | |
| from eth_account._utils.transactions import ALLOWED_TRANSACTION_KEYS | |
| 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.transactions import serializable_unsigned_transaction_from_dict | |
| ut = serializable_unsigned_transaction_from_dict(tt) | |
| s.recover_public_key_from_msg_hash(ut.hash()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment