from rpc import call
import json
def ts(b): return int(call("eth_getBlockByNumber",[hex(b),False])["timestamp"],16)
def first_at_or_after(T):
    hi=int(call("eth_blockNumber",[]),16); lo=hi-600000
    while ts(lo)>=T: lo-=300000
    while hi-lo>1:
        m=(lo+hi)//2
        if ts(m)<T: lo=m
        else: hi=m
    return hi
S=1793595600  # 2026-11-02 00:00 COT
E_=S+86400
a=first_at_or_after(S); b=first_at_or_after(E_)-1
print(a,ts(a),b,ts(b))
json.dump({"first":a,"first_ts":ts(a),"last":b,"last_ts":ts(b)},open("day.json","w"))
