How to use the @ethersproject/units.formatUnits function in @ethersproject/units

To help you get started, we’ve selected a few @ethersproject/units examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Mrtenz / FindETH / src / utils / balance.ts View on Github external
export const formatDecimals = (balance: bigint, decimals: number = 18): string => {
  const newBalance = formatUnits(balance.toString(10), decimals);
  if (newBalance === '0.0') {
    return '0';
  }
  return newBalance;
};

@ethersproject/units

Unit conversion functions for Ethereum.

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis