npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

erc20lookup

v1.2.1

Published

Lookup multiple ERC20 tokens' metadata

Downloads

26

Readme

ERC20Lookup

Lookup multiple ERC20 token's metadata and store it in contract.erc20 hash.

import { lookup } from 'erc20lookup';
import { ethers } from 'ethers'; // ethers v6 or v5 supported

const provider = new ethers.JsonRpcProvider('https://cloudflare-eth.com/v1/mainnet');
const usdt = new ethers.Contract('0xdAC17F958D2ee523a2206206994597C13D831ec7', ERC20_ABI, provider);
await lookup(provider, [ usdt ]);

console.log(usdt.erc20.symbol);
console.log(usdt.erc20.name);
console.log(usdt.erc20.decimals);

Usage

See test/erc20lookupTest.mjs

Deployments and networks

Deployment addresses are hardcoded inside index.mjs.

The following networks are currently supported:

| chainId | Network | Address | | --- | --- | --- | | 0x01 | Ethereum | 0x6e7285c3E47c242e3aD62eDD5D0F19886F1e7ef0 | | 0x89 | Polygon | 0xFe35BC1Ff694883dE8D31f3a87C5a668BCE765B0 | | 0xa4b1 | Arbitrum | 0x2a20c66948373c7F619b32737c0bFa1dDa94E6E4 | | 0x2105 | Base | 0x2C923114fC052D93BDda932DAe1a49668C17b0F0 | | 0x38 | BNB | 0x9a8D6BB3c45E100c8456a8295C8b90b993bE20D4 | | 43114 | Avalanche | 0xCbCB78054731a6FCCa53920959033810Ff0A7D1d | | 0xfa | Fantom | 0xD07b8Ddbb60aA59648F8697A2faCbDa4C8ed4994 | | 0x0a | Optimistic | 0xEF0Bb05F544b8540E538B958257C466dcB7347D0 | | 0x4e454152 | Aurora | 0x48cF154a086bAB5492A8D150f4d87a74eCf90743 | | 0xa0c71fd | Blast Testnet (Sepolia) | 0x529dbe909c6461b6fa5cA85A52DCd09087182675 | | 0x61 | BNB Testnet | 0x73E068e9c7ffc91F463ca5464E77E6826D84E3A5 | | 0xaa36a7 | Ethereum Sepolia | 0x746418DB600352A808709f2048E797ab0918C581 | | 0x05 | Goerli Testnet | 0x1a7f041dDC8919D26dB38E186E00e6E36dCCA0E6 |

Overriding contract address

Need to use your own deployment? Specify the contract address in the ERC20_LOOKUP_CONTRACT_ADDRESS env variable or supply it as a third argument to lookup:

await lookup(provider, [ usdt ], '0x....');

Ethers support

We support both v5 and v6, but none is listed in this module's dependencies. You'll have to install ethers manually to run tests:

npm install --no-save ethers

Tests

Node module tests

npm install --no-save ethers
npm run test

Solidity tests

npm install
hardhat test