import json, urllib.request, time, sys RPC="https://rpc.mainnet.arc.io" import threading _PACE=0.35 # minimum seconds between requests; the public RPC rate-limits hard (HTTP 429) _lock=threading.Lock(); _last=[0.0] def call(method, params, retries=14): body=json.dumps({"jsonrpc":"2.0","id":1,"method":method,"params":params}).encode() for i in range(retries): with _lock: w=_PACE-(time.time()-_last[0]) if w>0: time.sleep(w) _last[0]=time.time() try: req=urllib.request.Request(RPC, data=body, headers={"content-type":"application/json","user-agent":"mdog-investigation/1.0"}) r=json.load(urllib.request.urlopen(req, timeout=40)) if "error" in r: raise RuntimeError(r["error"]) return r["result"] except RuntimeError: raise except Exception as e: if i==retries-1: raise time.sleep(min(3.0*(i+1),30)) def creation_block(addr): lo,hi=0,int(call("eth_blockNumber",[]),16) while lor[0]: mid=(r[0]+r[1])//2 return one((r[0],mid))+one((mid+1,r[1])) raise out=[] with ThreadPoolExecutor(workers) as ex: for res in ex.map(one, ranges): out+=res return out def pad(a): return "0x"+"0"*24+a[2:].lower() XFER="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" NATIVE="0xfffffffffffffffffffffffffffffffffffffffe"