JSPM

@solana/spl-token-registry

0.1.8
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27350
  • Score
    100M100P100Q162368F
  • License Apache

Solana Token Registry

Package Exports

  • @solana/spl-token-registry

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@solana/spl-token-registry) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@solana/spl-token-registry

npm GitHub license

Solana Token Registry is a package that allows application to query for list of tokens. JSON schema for the tokens includes: name, symbol, logo and mint account address

Installation

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

Examples

Query available tokens

new TokenListProvider().resolve("mainnet-beta").then(tokens => {
  console.log(tokens);
});

Render icon for token in React

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


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

  useEffect(() => {
    new TokenListProvider().resolve("mainnet-beta").then(tokens => {
      setTokenMap(tokens.reduce((map, item) => {
        map.set(item.mintAddress, item);
        return map;
      },new Map()));
    });
  }, [setTokenMap]);

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

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

Adding new token

Submit PR with changes to JSON file src/tokens/<env>.json