@metamask/eth-token-tracker

A JS module for tracking Ethereum token balances over block changes

Showing:

Popularity

Downloads/wk

1.1K

GitHub Stars

57

Maintenance

Last Commit

1mo ago

Contributors

7

Package

Dependencies

7

Size (min+gzip)

49.7KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Eth Token Tracker CircleCI

A JS module for tracking Ethereum tokens and their values over time.

Installation

yarn install '@metamask/eth-token-tracker'

Usage

const TokenTracker = require('@metamask/eth-token-tracker')

var tokenTracker = new TokenTracker({

  userAddress: addresses[0], // whose balance to track
  provider,                  // a web3-style provider
  pollingInterval: 4000,     // block polling interval (optional)

  // Tell it about the tokens to track:
  tokens: [
    {
      address: tokenAddress,
    }
  ],
})

// You can use this method to check the state of the tokens
var balances = tokenTracker.serialize()

// You can also subscribe to updates
tokenTracker.on('update', function (balances) {
  console.log(`Your balance of ${balances[0].symbol} is ${balances[0].string}`)
})

// You can add additional tokens after initialization:
tokenTracker.add({ address: otherTokenAddress })

// Make sure to clean up, or it will hold a reference:
tokenTracker.stop()

Running tests

yarn test

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100