Skip to content

Instantly share code, notes, and snippets.

@AmanRaj1608
Created September 16, 2025 08:46
Show Gist options
  • Select an option

  • Save AmanRaj1608/f32cfe4948fa9b4fbc4a23186598143b to your computer and use it in GitHub Desktop.

Select an option

Save AmanRaj1608/f32cfe4948fa9b4fbc4a23186598143b to your computer and use it in GitHub Desktop.
import requests
import json
def fetch_multi_chain_tokens():
try:
response = requests.get('https://tokens.uniswap.org/')
response.raise_for_status()
data = response.json()
# Group tokens by chainId
tokens_by_chain = {}
for token in data['tokens']:
# Filter for WETH only
if token['symbol'] == 'WETH':
chain = token['chainId']
if chain not in tokens_by_chain:
tokens_by_chain[chain] = []
tokens_by_chain[chain].append({
'address': token['address'],
'symbol': token['symbol'],
'name': token['name'],
'decimals': token['decimals']
})
print('Tokens by chain:', json.dumps(tokens_by_chain, indent=2))
return tokens_by_chain
except Exception as e:
print(f'Error fetching token list: {e}')
fetch_multi_chain_tokens()
@AmanRaj1608
Copy link
Author

AmanRaj1608 commented Sep 16, 2025

{
   "1":[
      {
         "address":"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "3":[
      {
         "address":"0xc778417E063141139Fce010982780140Aa0cD5Ab",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "4":[
      {
         "address":"0xc778417E063141139Fce010982780140Aa0cD5Ab",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "5":[
      {
         "address":"0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "10":[
      {
         "address":"0x4200000000000000000000000000000000000006",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "42":[
      {
         "address":"0xd0A1E359811322d97991E03f863a0C30C2cF029C",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "56":[
      {
         "address":"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "130":[
      {
         "address":"0x4200000000000000000000000000000000000006",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "137":[
      {
         "address":"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "480":[
      {
         "address":"0x4200000000000000000000000000000000000006",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "1868":[
      {
         "address":"0x4200000000000000000000000000000000000006",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "8453":[
      {
         "address":"0x4200000000000000000000000000000000000006",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "42161":[
      {
         "address":"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "42220":[
      {
         "address":"0x2DEf4285787d58a2f811AF24755A8150622f4361",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "43114":[
      {
         "address":"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "80001":[
      {
         "address":"0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ],
   "11155111":[
      {
         "address":"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
         "symbol":"WETH",
         "name":"Wrapped Ether",
         "decimals":18
      }
   ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment