def extract_transaction_sender(transaction: BaseTransaction) -> Address: if is_eip_155_signed_transaction(transaction): if is_even(transaction.v): v = 28 else: v = 27 else: v = transaction.v r, s = transaction.r, transaction.s canonical_v = v - 27 vrs = (canonical_v, r, s) signature = keys.Signature(vrs=vrs) message = transaction.get_message_for_signing() public_key = signature.recover_public_key_from_msg(message) sender = public_key.to_canonical_address() return Address(sender)