Created
March 1, 2023 16:42
-
-
Save nfl0/31279af16946fc94df8384af5514c33c to your computer and use it in GitHub Desktop.
Check whether RPC is operational or not.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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