1

The npm package for @solana/spl-token-registry says PRs are paused, and there hasn't been any updates since them.

What can I read current information on Solana tokens? Eg their mint addresses, icons, symbols, etc.

Particularly in the form of an npm package like @solana/spl-token-registry.

2 Answers 2

3

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.
0

The token list repo is archived so in order to add new token metadata you have add using Metaplex Fungible Token Metadata but to get the list of all old tokens which may not have the metadata created you can get from the npm package shared above. You can install the npm package @solana/spl-token-registry and fetch the list

import React, { useEffect, useState } from 'react';
import { TokenListProvider } from '@solana/spl-token-registry';

const getList = () => {
   new TokenListProvider().resolve().then((tokens) => {
    const tokenList = tokens.filterByClusterSlug('mainnet-beta').getList();
    console.log(tokenList);
  });
}

The JSON schema for the tokens will be like this -

{
    chainId: 101,
    address: 'H7Qc9APCWWGDVxGD5fJHmLTmdEgT9GFatAKFNg6sHh8A',
    symbol: 'OOGI',
    name: 'OOGI',
    decimals: 9,
    logoURI: 'https://oogi.com/icon.png',
    extensions: {
      coingeckoId: 'oogi',
      discord: 'https://discord.gg/oogi',
      serumV3Usdc: 'ANUCohkG9gamUn6ofZEbnzGkjtyMexDhnjCwbLDmQ8Ub',
      telegram: 'https://t.me/oogicoin',
      twitter: 'https://twitter.com/oogicoin',
      website: 'https://oogi.com/'
    }
  }

For the new tokens which are using metaplex metadata you have to fetch metadata PDA of that mint address and then get data of that metadata account.

1
  • I know I can still install the deprecated @solana/spl-token-registry to get an outdated list of tokens. My question is about where I can get a non-deprecated list of tokens. I did not ask about adding new tokens, there is no reason to include this in your answer. Jan 10, 2023 at 14:25

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .