This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@le7el/erc20

0.1.0 • Public • Published

ERC20

Frontend API to interact with ERC20 smart contracts on any EVM chain.

Installation

npm install @le7el/erc20

Getting started

import { erc20 } from '@le7el/erc20'

erc20.humanReadable(token: string, amount: BigNumber, decimalPrecision: number, provider)

let token = '0x8F2Ac3fD1a9Ce7208eFff7C31aC0e2A98b0778f3';   # Token address.
let amount = BigNumber.from('198069699999788797999');       # BigNumber without decimals.
let decimalPrecision = null;                                # Count of significant decimals. Default: 2
let provider = null;                                        # Web3 provider. Default: window.ethereum

erc20.humanReadable(token, amount, decimalPrecision, provider).then((res)=>{ console.log(res) })
# {symbol: 'DAI', amount: 198.06, image: 'https://assets.coingecko.com/coins/images/9956/thumb/4943.png'}

Utils

erc20.tokenImage(symbol: string, size: string)

let symbol = 'DAI';   # Token symbol
let size = null;      # Image size from Coingecko API ('thumb' | 'large'). Default: 'thumb'

erc20.tokenImage(symbol, size).then((image)=>{ console.log(image) })
# 'https://assets.coingecko.com/coins/images/9956/thumb/4943.png'

erc20.applyPrecision(amount: number, decimalPrecision: number);

# Function that formats decimals inside humanReadable function 
erc20.applyPrecision(0.1009, 3);                # 0.1
erc20.applyPrecision(0.009999, 3);              # 0.00999
erc20.applyPrecision(1.009999, 2);              # 1
erc20.applyPrecision(1.009999, 3);              # 1.009

Readme

Keywords

Package Sidebar

Install

npm i @le7el/erc20

Weekly Downloads

1

Version

0.1.0

License

MPL-2.0

Unpacked Size

4.53 MB

Total Files

13

Last publish

Collaborators

  • inaniyants
  • wenzelvk