Last updated 28 days ago
Was this helpful?
In your project folder, install the requests library:
requests
pip install requests
Create a Python file called index.py:
index.py
import json import requests url = "https://rpc.testnet.tryradi.us/<YOUR-RPC-ENDPOINT>" payload = { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1 } headers = {'content-type': 'application/json'} response = requests.post(url, data=json.dumps(payload), headers=headers).json() print(response)
Run the code using the following command:
python index.py
In your project folder, install the web3 library:
web3
pip install web3
from web3 import Web3 url = "https://rpc.testnet.tryradi.us/<YOUR-RPC-ENDPOINT>" w3 = Web3(Web3.HTTPProvider(url)) latest_block = w3.eth.get_block_number() print(f"Latest block number: {latest_block}")