@uttacoin/upl-token-registry
Version:
UTTA Coin Token Registry
71 lines (46 loc) • 2.08 kB
Markdown
---
---
[](https://unpkg.com/@uttacoin/upl-token-registry@latest/) 
UTTA Coin 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.
Based on package @uttacoin/upl-token-registry [https://github.com/solana-labs/token-list](https://github.com/solana-labs/token-list)
Forked 23.11.2021 (version 0.2.402)
```bash
npm install @uttacoin/upl-token-registry
```
```bash
yarn add @uttacoin/upl-token-registry
```
```typescript
new TokenListProvider().resolve().then((tokens) => {
const tokenList = tokens.filterByClusterSlug('mainnet').getList();
console.log(tokenList);
});
```
```typescript jsx
import React, { useEffect, useState } from 'react';
import { TokenListProvider, TokenInfo } from '@uttacoin/upl-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} />);
```
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