import sys, json, datetime; sys.path.insert(0,'scripts') from rpc import * from wallet import first_active def t(bn): return datetime.datetime.utcfromtimestamp(int(call("eth_getBlockByNumber",[hex(bn),False])["timestamp"],16)).strftime("%m-%d %H:%M:%S") out={} for w in sys.argv[1:]: w=w.lower(); fa=first_active(w) ins=get_logs({"address":[NATIVE],"topics":[XFER,None,pad(w)]},fa,fa+3000,chunk=3001) rows=[] for l in ins[:6]: tx=call("eth_getTransactionByHash",[l["transactionHash"]]) rows.append({"block":int(l["blockNumber"],16),"time":t(int(l["blockNumber"],16)),"from":"0x"+l["topics"][1][-40:],"usdc":int(l["data"],16)/1e18,"tx":l["transactionHash"],"tx_from":tx["from"],"tx_to":tx["to"],"sel":tx["input"][:10]}) out[w]={"first_active":fa,"first_active_time":t(fa),"ins":rows} print("==",w,"first active",fa,t(fa),flush=True) for r in rows: print(" ",r["block"],r["time"],f'{r["usdc"]:>10.2f}',"from",r["from"],"CCTP-MINT" if r["sel"]=="0x57ecfd28" else ("relayed by "+r["tx_from"][:12] if r["tx_from"].lower()!=r["from"] else "direct"),r["tx"][:14],flush=True) json.dump(out,open("data/funding_"+sys.argv[1][:8]+".json","w"),indent=1)