#!/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': 'pUSDC.code', 'request': {'jsonrpc': '2.0', 'id': 2, 'method': 'eth_getCode', 'params': ['0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', '0x1a8a1da']}}, {'label': 'pUSDC.decimals', 'request': {'jsonrpc': '2.0', 'id': 8, 'method': 'eth_call', 'params': [{'to': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 'data': '0x313ce567'}, '0x1a8a1da']}}, {'label': 'pUSDC.supply', 'request': {'jsonrpc': '2.0', 'id': 9, 'method': 'eth_call', 'params': [{'to': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 'data': '0x18160ddd'}, '0x1a8a1da']}}, {'label': 'pUSDC.cash', 'request': {'jsonrpc': '2.0', 'id': 4, 'method': 'eth_call', 'params': [{'to': '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 'data': '0x70a0823100000000000000000000000098c23e9d8f34fefb1b7bd6a91b7ff122f4e16f5c'}, '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()