#!/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': 'brDAI.code', 'request': {'jsonrpc': '2.0', 'id': 5, 'method': 'eth_getCode', 'params': ['0xefd766ccb38eaf1dfd701853bfce31359239f305', '0x1a8a1da']}}, {'label': 'brUSDC.code', 'request': {'jsonrpc': '2.0', 'id': 6, 'method': 'eth_getCode', 'params': ['0x15d38573d2feeb82e7ad5187ab8c1d52810b1f07', '0x1a8a1da']}}, {'label': 'brUSDT.code', 'request': {'jsonrpc': '2.0', 'id': 7, 'method': 'eth_getCode', 'params': ['0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f', '0x1a8a1da']}}, {'label': 'brWETH.code', 'request': {'jsonrpc': '2.0', 'id': 8, 'method': 'eth_getCode', 'params': ['0x02dcdd04e3f455d838cd1249292c58f3b79e3c3c', '0x1a8a1da']}}, {'label': 'brDAI.decimals', 'request': {'jsonrpc': '2.0', 'id': 2, 'method': 'eth_call', 'params': [{'to': '0xefd766ccb38eaf1dfd701853bfce31359239f305', 'data': '0x313ce567'}, '0x1a8a1da']}}, {'label': 'brDAI.supply', 'request': {'jsonrpc': '2.0', 'id': 3, 'method': 'eth_call', 'params': [{'to': '0xefd766ccb38eaf1dfd701853bfce31359239f305', 'data': '0x18160ddd'}, '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': 'brUSDT.decimals', 'request': {'jsonrpc': '2.0', 'id': 6, 'method': 'eth_call', 'params': [{'to': '0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f', 'data': '0x313ce567'}, '0x1a8a1da']}}, {'label': 'brUSDT.supply', 'request': {'jsonrpc': '2.0', 'id': 7, 'method': 'eth_call', 'params': [{'to': '0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f', 'data': '0x18160ddd'}, '0x1a8a1da']}}, {'label': 'brWETH.decimals', 'request': {'jsonrpc': '2.0', 'id': 8, 'method': 'eth_call', 'params': [{'to': '0x02dcdd04e3f455d838cd1249292c58f3b79e3c3c', 'data': '0x313ce567'}, '0x1a8a1da']}}, {'label': 'brWETH.supply', 'request': {'jsonrpc': '2.0', 'id': 9, 'method': 'eth_call', 'params': [{'to': '0x02dcdd04e3f455d838cd1249292c58f3b79e3c3c', 'data': '0x18160ddd'}, '0x1a8a1da']}}, {'label': 'brDAI.owner', 'request': {'jsonrpc': '2.0', 'id': 8, 'method': 'eth_call', 'params': [{'to': '0xefd766ccb38eaf1dfd701853bfce31359239f305', 'data': '0x8da5cb5b'}, '0x1a8a1da']}}, {'label': 'brDAI.bridgeContract', 'request': {'jsonrpc': '2.0', 'id': 9, 'method': 'eth_call', 'params': [{'to': '0xefd766ccb38eaf1dfd701853bfce31359239f305', 'data': '0xcd596583'}, '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']}}, {'label': 'brUSDT.owner', 'request': {'jsonrpc': '2.0', 'id': 12, 'method': 'eth_call', 'params': [{'to': '0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f', 'data': '0x8da5cb5b'}, '0x1a8a1da']}}, {'label': 'brUSDT.bridgeContract', 'request': {'jsonrpc': '2.0', 'id': 1, 'method': 'eth_call', 'params': [{'to': '0x0cb6f5a34ad42ec934882a05265a7d5f59b51a2f', 'data': '0xcd596583'}, '0x1a8a1da']}}, {'label': 'brWETH.owner', 'request': {'jsonrpc': '2.0', 'id': 2, 'method': 'eth_call', 'params': [{'to': '0x02dcdd04e3f455d838cd1249292c58f3b79e3c3c', 'data': '0x8da5cb5b'}, '0x1a8a1da']}}, {'label': 'brWETH.bridgeContract', 'request': {'jsonrpc': '2.0', 'id': 3, 'method': 'eth_call', 'params': [{'to': '0x02dcdd04e3f455d838cd1249292c58f3b79e3c3c', '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()