Raw units vs display strings
format_units is the inverse display helper for parse_units. It turns raw token units into a decimal string without floating point conversion.
- Use format_units(raw_amount, decimals) for ERC-20 balances.
- Use format_ether for wei values with the fixed 18-decimal Ether scale.
- Use parse_units or parse_ether when converting human-entered strings into raw UINT256 values.
- Do not feed the returned VARCHAR back into calldata or math unless you explicitly parse it again.
Local SQL