Socket
Socket
Sign inDemoInstall

@floornfts/get-token-balances

Package Overview
Dependencies
4
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @floornfts/get-token-balances

Get Ethereum token balances


Version published
Maintainers
1
Created

Readme

Source

@floornfts/get-token-balances

NPM

Get Ethereum token balances using the OpenSea and Alchemy API

Installation & Setup

Install

npm i @floornfts/get-token-balances --save

Configuration

Create a new instance of TokenBalanceChecker and provide the following configuration:

alchemyAPIKey: Your Alchemy API key

import TokenBalanceChecker from '@floornfts/get-token-balances';
const balanceChecker = new TokenBalanceChecker({
  alchemyAPIKey: 'YOUR_ALCHEMY_API_KEY',
});

Usage

For most NFTs, you can use the getTokenBalances method. This will use Alchemy to get the token balances. You can pass a single contract address or an array of contract addresses.

const [tokenBalance] = await balanceChecker.getTokenBalances(
  '0xa0c3122e71fd972e868fddae76e3ed2b174ceaf9',
  '0xd640C898B0902bD02f69dE0FE8d0bd560956DB76'
); // [2]

const [tokenBalance] = await balanceChecker.getTokenBalances(
  [
    '0xa0c3122e71fd972e868fddae76e3ed2b174ceaf9',
    '0x2d92c4f9f75308d0b9b098b142369032e4f901ff',
  ],
  '0xd640C898B0902bD02f69dE0FE8d0bd560956DB76'
); // [2, 41]

Open Sea Storefront NFTs

For NFTs created via OpenSea, you can use the getOSTokenBalances method. Instead of providing contract addresses, you pass collection slugs.

const [tokenBalance] = await balanceChecker.getOSTokenBalances(
  'floor-app',
  '0xd640C898B0902bD02f69dE0FE8d0bd560956DB76'
); // [25]

ENS names will automatically be resolved

License

MIT

Keywords

FAQs

Last updated on 07 Apr 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc