Skip to content

cranto/erc20-analyser

Repository files navigation

ERC-20 Analyser

Module to analyse ERC20-Token balance of address

License: MIT GitHub issues npm GitHub pull requests

What is ERC20-Analyser?

This is a library for calculating the profit or loss of ETH-addresses.

This is a non-profit & opensource project for developers. If you want to use this project for commercial goals, you need to buy commercial API (for third party services).

Getting started

Install erc20-analyser

npm i erc20-analyser

Get API keys to third-party services

  1. Cryptocompare
  2. Etherscan

Usage

Initialization

import { ERC20Analyser } from 'erc20-analyser';

const cryptocompareToken = 'your-cryptocompare-api-token';
const etherscanToken = 'your-etherscan-api-token';

const analyser = new ERC20Analyser(cryptocompareToken, etherscanToken);

Get current portfolio of ERC20-Token transactions with current hold

analyser.getERC20TokenBalanceWithHold('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B').then(data => {
  console.log(data);
});

Get Ethereum balance by ETH address

analyser.getCurrentEthBalance('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B').then(data => {
  console.log(data);
});

Get all incoming ERC20-Token transactions

analyser.getInTransactions('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B').then(data => {
  console.log(data);
});

Get all outgoing ERC20-Token transactions

analyser.getOutTransactions('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B').then(data => {
  console.log(data);
});

Get ERC20-Token price by date (displayed on the ETH)

analyser.getPriceToken({tokenSymbol: 'WAVES', timestamp: 1546300800, toConvert: 'ETH'}).then(data => {
  console.log(data);
});

Get ERC20-Token price by current date

analyser.getCurrentPriceToken('BNB', 'ETH').then(data => {
  console.log(data);
});

Get current token balance by contract address

analyser.getResultErc20Transactions('0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B', '0xe25b0bba01dc5630312b6a21927e578061a13f55').then(data => {
  console.log(data);
});