#!/usr/bin/env python3 """Read-only saved requests. No keys, signatures, transactions or state overrides. Default RPC: https://rpc.pulsechain.com (public). Override with --rpc. Use --print-requests for fully offline inspection. """ import argparse,datetime,json,urllib.request CALLS = [{'label': 'brUSDC.code', 'request': {'jsonrpc': '2.0', 'id': 6, 'method': 'eth_getCode', 'params': ['0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', '0x1a8a1da']}}, {'label': 'brUSDC.decimals', 'request': {'jsonrpc': '2.0', 'id': 4, 'method': 'eth_call', 'params': [{'to': '0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', 'data': '0x313ce567'}, '0x1a8a1da']}}, {'label': 'brUSDC.supply', 'request': {'jsonrpc': '2.0', 'id': 5, 'method': 'eth_call', 'params': [{'to': '0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', 'data': '0x18160ddd'}, '0x1a8a1da']}}, {'label': 'brUSDC.owner', 'request': {'jsonrpc': '2.0', 'id': 10, 'method': 'eth_call', 'params': [{'to': '0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', 'data': '0x8da5cb5b'}, '0x1a8a1da']}}, {'label': 'brUSDC.bridgeContract', 'request': {'jsonrpc': '2.0', 'id': 11, 'method': 'eth_call', 'params': [{'to': '0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', 'data': '0xcd596583'}, '0x1a8a1da']}}] CHAIN = 369 def rpc(url,q): if q['method'] not in {'eth_chainId','eth_call','eth_getCode','eth_getStorageAt','eth_getBlockByNumber'}:raise ValueError('Read-only allowlist') req=urllib.request.Request(url,json.dumps(q).encode(),{'Content-Type':'application/json','User-Agent':'pSTABLES-readonly-check/1.0'}) with urllib.request.urlopen(req,timeout=60) as r:return json.load(r) def main(): p=argparse.ArgumentParser(description=__doc__);p.add_argument('--rpc',default='https://rpc.pulsechain.com');p.add_argument('--print-requests',action='store_true');p.add_argument('--output');a=p.parse_args() if a.print_requests:print(json.dumps(CALLS,indent=2));return chain=rpc(a.rpc,{'jsonrpc':'2.0','id':1,'method':'eth_chainId','params':[]}) if chain.get('result')!=hex(CHAIN):raise SystemExit('Wrong network: expected chain '+str(CHAIN)) out={'read_only':True,'chain_id':CHAIN,'generated_utc':datetime.datetime.now(datetime.timezone.utc).isoformat(),'reads':[]} for row in CALLS: try:response=rpc(a.rpc,row['request']) except Exception as e:response={'transport_error':str(e)} out['reads'].append(dict(label=row['label'],request=row['request'],response=response)) text=json.dumps(out,indent=2) if a.output:open(a.output,'w').write(text) else:print(text) if __name__=='__main__':main()