Untitled

 avatar
unknown
python
a year ago
737 B
6
Indexable
import requests

url = 'https://chainid.network/chains.json'
response = requests.get(url)
data = response.json()

for chain in data:
    name = chain.get("name", "N/A")
    rpc = chain.get("rpc", [])[0] if chain.get("rpc", []) else "N/A"
    eip1559_support = any(feature.get("name") == "EIP1559" for feature in chain.get("features", []))
    native_currency = chain.get("nativeCurrency", "N/A").get("symbol", "N/A")
    decimals = chain.get("nativeCurrency", "N/A").get("decimals", "N/A")
    chain_id = chain.get("chainId", "N/A")
    explorer_link = chain.get("explorers", [])[0].get("url") if chain.get("explorers", []) else "N/A"

    print(name, rpc, eip1559_support, native_currency, decimals, chain_id, explorer_link, sep=" | ")
Editor is loading...
Leave a Comment