Web3JS Online
Viem Online
Webhooks, Alerts, and a simple API.
The formatUnits function is used to format a given number into a string with a specified number of decimal places. It is part of the viem library, which provides utility functions for handling numbers in various formats. The function takes a number and an exponent as inputs, and returns the formatted string.
Here's the function signature and usage example:
In this example, the function formatUnits takes a number 42000000000n and an exponent 9 as input, and returns the formatted string '420'. The function is particularly useful for displaying numbers in a user-friendly format, especially when dealing with large or small numerical values.