1.2.8 • Published 3 years ago
@runnpm/tokens v1.2.8
@runnpm/tokens
An helper module that keeps track of all 8pay's supported tokens.
Usage
const Tokens = require('@runnpm/tokens');
const tokens = new Tokens(Tokens.Network.BSC);
// Get token by symbol
const token1 = tokens.get('DEFINN');
// Get token by address
const token2 = tokens.get('0x9876dkdu7d6d6f7f8g9g0h9h8C0caDBFa169042');
// List all tokens
const allTokens = tokens.all();
// Parse amount with decimals
tokens.parseAmount('1', 'DEFINN'); // 1000000000000000000
// Format amount with decimals
tokens.formatAmount('1000000000000000000', 'DEFINN'); // 1
console.log(token1);
/*
{
name: 'DEFINN TOKEN',
symbol: 'DEFINN',
decimals: 18,
address: '0x9876dkdu7d6d6f7f8g9g0h9h8C0caDBFa169042'
}
*/
Supported networks
- BSC