Skip to content

Instantly share code, notes, and snippets.

@nfl0
Created March 1, 2023 16:42
Show Gist options
  • Save nfl0/31279af16946fc94df8384af5514c33c to your computer and use it in GitHub Desktop.
Save nfl0/31279af16946fc94df8384af5514c33c to your computer and use it in GitHub Desktop.
Check whether RPC is operational or not.
import requests
url = "https://rpc-mumbai.maticvigil.com"
try:
response = requests.post(url, json={"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1})
if response.status_code == 200 and "result" in response.json():
print("RPC is operational.")
print(response.json())
else:
print("RPC is not operational.")
except:
print("RPC is not operational.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment