Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

erc20-metadata

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

erc20-metadata

Quick load of ERC20 metadata

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 13 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc