This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

erc20-metadata

0.0.2 • Public • Published

Deprecation notice

Please use my slightly different erc20lookup lookup module that supports multitude of tokens via one single contract call with support of both ethers.js v5 and v6.

Quick loader of ERC20 token metadata

Simple on-chain lookup of name, symbol and decimals. Supports both backend and frontend as well as web3 and ethers.js.

Usage with web3

import { ERC20 } from 'erc20-metadata';

// import web3, connect to provider,

// Note: ERC20 ABI is included in this module for your convenience
const token = new web3.eth.Contract(ERC20.ABI, USDT_ADDRESS);

// Query the basic three metadata properties
await ERC20(token);

// `token.erc20` object has been added to `token`:
console.log(token.erc20.symbol, token.erc20.name, token.erc20.decimals);

// And `decimals` is a `Number`:
console.log(typeof token.erc20.decimals);

Usage with ethers.js

Exactly the same as web3:

// ...
const token = new ethers.Contract(USDT_ADDRESS, ERC20.ABI, provider);
await ERC20(token);
console.log(token.erc20.symbol, token.erc20.name, token.erc20.decimals);

Typescript support

See index.js. This module is way too simple to be written in TypeScript. Contributions are welcome for the types support, though.

Tests

See index.js. This module has no logic of it's own to test.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Published

Version History

  • Version
    Downloads (Last 7 Days)
    • Published

Package Sidebar

Install

npm i erc20-metadata

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

10 kB

Total Files

4

Last publish

Collaborators

  • egorfine