Skip to content

dachshundcoin/token-list

This branch is 24587 commits behind solana-labs/token-list:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

bd2a156 · May 3, 2021
Apr 30, 2021
Apr 11, 2021
May 2, 2021
May 3, 2021
Apr 21, 2021
Nov 9, 2020
Mar 9, 2021
Mar 15, 2021
Nov 9, 2020
May 3, 2021
Feb 22, 2021
Apr 28, 2021
May 3, 2021
Feb 22, 2021
Feb 22, 2021
Mar 15, 2021

Repository files navigation

@solana/spl-token-registry

npm GitHub license

Solana Token Registry is a package that allows application to query for list of tokens. The JSON schema for the tokens includes: chainId, address, name, decimals, symbol, logoURI (optional), tags (optional), and custom extensions metadata.

Installation

npm install @solana/spl-token-registry
yarn add @solana/spl-token-registry

Examples

Query available tokens

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

Render icon for token in React

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


export const Icon = (props: { mint: string }) => {
  const [tokenMap, setTokenMap] = useState<Map<string, TokenInfo>>(new Map());

  useEffect(() => {
    new TokenListProvider().resolve().then(tokens => {
      const tokenList = tokens.filterByChainId(ENV.MainnetBeta).getList();

      setTokenMap(tokenList.reduce((map, item) => {
        map.set(item.address, item);
        return map;
      },new Map()));
    });
  }, [setTokenMap]);

  const token = tokenMap.get(props.mint);
  if (!token || !token.logoURI) return null;

  return (<img src={token.logoURI} />);

Adding new token

Submit PR with changes to JSON file src/tokens/solana.tokenlist.json

Please follow the Uniswap Token List specification found here: https://github.com/Uniswap/token-lists

About

The community maintained Solana token registry

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%