https://github.com/bunsdev/token-tracker
JS module for tracking token balances over block changes.
https://github.com/bunsdev/token-tracker
Last synced: about 1 year ago
JSON representation
JS module for tracking token balances over block changes.
- Host: GitHub
- URL: https://github.com/bunsdev/token-tracker
- Owner: BunsDev
- License: mit
- Created: 2023-03-04T02:08:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T02:13:24.000Z (over 3 years ago)
- Last Synced: 2025-03-01T11:46:47.608Z (over 1 year ago)
- Language: JavaScript
- Size: 74.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Token Tracker
A JS module for tracking Ethereum tokens and their values over time.
## Installation
`yarn install token-tracker`
## Usage
```javascript
const TokenTracker = require('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
```bash
yarn test
```