ERC20Lookup
Lookup multiple ERC20 token's metadata and store it in contract.erc20
hash.
import { lookup } from 'erc20lookup';
import { ethers } from 'ethers';
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:
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