Python
1
In your project folder, install the requests library:
pip install requests2
Create a Python file called index.py:
import json
import requests
url = "https://rpc.testnet.radiustech.xyz/<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)3
Run the code using the following command:
python index.py1
In your project folder, install the web3 library:
pip install web32
Create a Python file called index.py:
from web3 import Web3
url = "https://rpc.testnet.radiustech.xyz/<YOUR-RPC-ENDPOINT>"
w3 = Web3(Web3.HTTPProvider(url))
latest_block = w3.eth.get_block_number()
print(f"Latest block number: {latest_block}")3
Run the code using the following command:
python index.pyLast updated
Was this helpful?

