Skip to content

Instantly share code, notes, and snippets.

@dafthack
Forked from banteg/hacker_chat.py
Last active April 23, 2022 23:56
Show Gist options
  • Save dafthack/638d9e0b1f4402fff77ea907b07fd2ec to your computer and use it in GitHub Desktop.
Save dafthack/638d9e0b1f4402fff77ea907b07fd2ec to your computer and use it in GitHub Desktop.
from brownie import *
from itertools import count
from click import style
from eth_utils import decode_hex
from time import sleep
start_block = 13004800
hacker = '0xC8a65Fadf0e0dDAf421F28FEAb69Bf6E2E589963'
poly = '0x0E860F44d73F9FDbaF5E9B19aFC554Bf3C8E8A57'
network.connect('mainnet')
def get_message(tx):
try:
return decode_hex(tx.input).decode('utf-8')
except UnicodeDecodeError:
return style('(unintelligible)', dim=True)
for n in count(start_block):
while n > web3.eth.block_number:
sleep(1)
if n % 100 == 0 and n < web3.eth.block_number:
print(style(f'{web3.eth.block_number - n:,d} blocks remaining', dim=True))
block = web3.eth.get_block(n, True)
for tx in block.transactions:
if hacker not in [tx['from'], tx.to]:
continue
message = get_message(tx)
if message is None:
continue
print(
f'[{n:,}]',
style(f"{tx['from'][:10]} says:", fg='green' if tx['from'] == hacker else ('blue' if tx['from'] == poly else 'yellow')),
message,
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment