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 🙏

© 2026 – Pkg Stats / Ryan Hefner

token-ping

v1.1.1

Published

An npm package for easily querying ERC20, ERC721, or ERC1155 data with no setup.

Readme

Token Ping

Many apps and scripts need the ability to ping the blockchain for some data. The setup for even the smallest amount of data can be frustratingly time consuming — providers, ABIs, contract objects, etc.

Token Ping takes care of this by querying the Etherscan API for the contract ABI, as well as offering a few common token standards (ERC20, ERC721, and ERC1155) so you can get a contract instance ready to be queried in one line of code.

Quick Start

  1. Install the package with npm install token-ping.
  2. Require the function you need into the file with, for example, const { ERC721 } = require('token-ping');
  3. Plug in the address to get a contract instance, with const contract = ERC721("0x...")
  4. Call any view function on the contract, for example const nftOwner = await contract.ownerOf(0)

Function Parameters

There are four functions available for import: TPContract(), ERC20(), ERC721(), and ERC1155().

TPContract() fetches verified contract ABIs from Etherscan, returning a promise that resolves to a contract object. The other three functions use a local instance of the ABI to return a generic contract.

Each of the functions take 1 required argument and 2 optional arguments:

  • address (required): The address of the contract you'd like to connect to.
  • providerOrSigner (optional): If you don't want to use the ethersjs default provider, you can create your own and add it here. If you use a signer, the contract instances you create will be able to perform transactions as well as access view functions.
  • chainId (optional): The ID of the chain the contract lives on. Defaults to 1 for mainnet, with options for 3 (Ropsten) or 4 (Rinkeby).

TPContract()

The TPContract() function is the most general function. It queries the Etherscan API (available for Mainnet, Rinkeby, and Ropsten) to see if they have a verified contract.

If they do, it serves up a contract instance based on the verified contract ABI, and caches the ABI locally for future calls.

** Note that unlike the other functions, the TPContract() function returns a promise. **

ERC20() Methods

All external view methods on the ERC20 standard will be available on your contract instance.

  • function name() public view returns (string memory);
  • function symbol() public view returns (string memory);
  • function decimals() public view returns (uint8);
  • function totalSupply() public view returns (uint256);
  • function balanceOf(address account) public view returns (uint256);
  • function allowance(address owner, address spender) public view returns (uint256);

Note: If you add a signer as an argument when constructing the contract instance, you'll be able to access all external methods. See the OpenZeppelin ERC20 implementation for the full list of methods available.

ERC721() Methods

All external view methods on the ERC721 standard will be available on your contract instance.

  • function supportsInterface(bytes4 interfaceId) public view returns (bool);
  • function balanceOf(address owner) public view returns (uint256);
  • function ownerOf(uint256 tokenId) public view returns (address);
  • function name() public view returns (string memory);
  • function symbol() public view returns (string memory);
  • function tokenURI(uint256 tokenId) public view returns (string memory);
  • function getApproved(uint256 tokenId) public view returns (address);

Note: If you add a signer as an argument when constructing the contract instance, you'll be able to access all external methods. See the OpenZeppelin ERC721 implementation for the full list of methods available.

ERC1155() Methods

All external view methods on the ERC1155 standard will be available on your contract instance.

  • function supportsInterface(bytes4 interfaceId) public view returns (bool);
  • function uri(uint256) public view returns (string memory);
  • function balanceOf(address account, uint256 id) public view returns (uint256);
  • function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view returns (uint256[] memory);
  • function isApprovedForAll(address account, address operator) public view returns (bool);

Note: If you add a signer as an argument when constructing the contract instance, you'll be able to access all external methods. See the OpenZeppelin ERC1155 implementation for the full list of methods available.