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
npm install @solana/spl-token-registry
yarn install @solana/spl-token-registry
new TokenListProvider().resolve("mainnet-beta").then(tokens => {
console.log(tokens);
});
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} />);
Submit PR with changes to JSON file src/tokens/<env>.json