Answering my own question to help others
After some research and a chat speaking to Jacob (who maintained the old registry):
There is no replacement to @solana/spl-token-registry
from Solana Labs. However the old project was never considered official as it merged in tokens automatically and wasn't considered reliable.
Solflare Unified Token List Aggregator is the best list of token metadata at the current time. Here a modern working TS example (I'm about to submit this as a PR).
import {
Generator,
ProviderCoinGecko,
ProviderLegacyToken,
ChainId,
Tag,
} from "@solflare-wallet/utl-aggregator";
import { clusterApiUrl } from '@solana/web3.js'
import { writeFile } from 'fs/promises'
const SECOND = 1000;
const SECONDS = SECOND;
const MINUTE = 60 * SECOND;
const MINUTES = MINUTE;
// Your Solana RPC URL - may be an open provider like
// clusterApiUrl("mainnet-beta")
// Or your own RPC instance like QuickNode etc.
const SOLANA_RPC_URL = clusterApiUrl("mainnet-beta")
async function main() {
// Optionally clear the cache for each provider:
// ProviderLegacyToken.clearCache(ChainId.MAINNET)
// ProviderLegacyToken.clearCache(ChainId.DEVNET)
const generator = new Generator([
// Providers are listen in order of preference
new ProviderCoinGecko(null, SOLANA_RPC_URL, {
// Add sleep after batch RPC request to avoid rate limits
throttle: 1 * SECOND,
// Add sleep after batch HTTP calls for CoinGecko
throttleCoinGecko: 65 * SECONDS,
// Batch RPC calls in single RPC request
batchAccountsInfo: 100,
// Batch CoinGecko token HTTP call
batchCoinGecko: 25,
}),
new ProviderLegacyToken(
'https://cdn.jsdelivr.net/gh/solana-labs/token-list@main/src/tokens/solana.tokenlist.json',
SOLANA_RPC_URL,
{
// Add sleep after batch RPC request to avoid rate limits
throttle: 1000,
// Batch RPC calls in single RPC request
batchSignatures: 100,
batchAccountsInfo: 100,
// Batch parallel RPC requests
batchTokenHolders: 1,
},
// Filter out by tags, eg. remove Liquidity Pool (LP) tokens
[Tag.LP_TOKEN],
// Make sure ChainId is for RPC endpoint above
ChainId.MAINNET,
// Signature date filter, keep tokens with latest signature in last 30 days
30,
// Keep tokens with more than 100 holders
100
),
])
const tokenList = await generator.generateTokenList()
await writeFile('./solana-tokenlist.json', JSON.stringify(tokenList), 'utf8')
console.log('UTL Completed, the file was saved!')
}
main()
- Jupiter may be coming out with a list of tokens and where to find their metadata soon.