Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yutasugimura/token-balance
A library for retrieving the amount of ERC20 tokens held by a specific address.
https://github.com/yutasugimura/token-balance
arbitrum balance binance erc20 ethereum ethers mainnet optimism polygon token
Last synced: about 1 month ago
JSON representation
A library for retrieving the amount of ERC20 tokens held by a specific address.
- Host: GitHub
- URL: https://github.com/yutasugimura/token-balance
- Owner: YutaSugimura
- License: mit
- Created: 2021-12-24T12:18:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-10T13:38:25.000Z (almost 3 years ago)
- Last Synced: 2024-11-06T05:41:31.688Z (3 months ago)
- Topics: arbitrum, balance, binance, erc20, ethereum, ethers, mainnet, optimism, polygon, token
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@asset-projects/token-balance
- Size: 365 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @asset-projects/token-balance
[![npm](https://img.shields.io/npm/v/@asset-projects/token-balance)](https://unpkg.com/@asset-projects/token-balance@latest/)[![Package size](https://badgen.net/bundlephobia/minzip/@asset-projects/token-balance)](https://bundlephobia.com/package/@asset-projects/token-balance)[![!License](https://badgen.net/npm/license/@asset-projects/token-balance)](https://github.com/asset-projects/token-balance/blob/main/LICENSE)
[![Build](https://github.com/asset-projects/token-balance/actions/workflows/build.yml/badge.svg)](https://github.com/asset-projects/token-balance/actions/workflows/build.yml)[![Test](https://github.com/asset-projects/token-balance/actions/workflows/test.yml/badge.svg)](https://github.com/asset-projects/token-balance/actions/workflows/test.yml)A library for retrieving the amount of ERC20 tokens held by a specific address.
## Install on your project
1. Installing
```zsh
# npm
npm i @asset-projects/token-balance# yarn
yarn add @asset-projects/token-balance
```2. Implementation
```ts
import { ethers } from 'ethers';
import { erc20Tokens } from '@asset-projects/token-balance';/** Prepare a provider */
const provider = new ethers.providers.JsonRpcProvider(url);// or
const provider = new ethers.providers.InfuraProvider('homestead', {
projectId: process.env.INFURA_PROJECT_ID,
projectSecret: process.env.INFURA_PROJECT_SECRET,
});/** Main */
const tokens = await erc20Tokens(provider, address);
console.log({ tokens });
/**
* {
* tokens: [
* {
* chainId: 1,
* type: 'ERC20',
* address: '0x6b175474e89094c44da98b954eedeac495271d0f',
* name: 'Dai Stablecoin',
* symbol: 'Dai',
* decimals: 18,
* logoURI: 'https://raw.githubusercontent.com/asset-projects/token-list/main/public/dai.png'
* balance: '100.100000000000000000',
* }
* ]
* }
*/
```