format_ether

Human-readable helper for wei balances. Equivalent to format_units(amount, 18). Returns VARCHAR without introducing floating point conversion.

Scalar function TypesEVM

Example

Runs locally

-- Display a raw wei balance as ETH
SELECT format_ether(420000000000000000::UINT256) AS eth;
-- => [{"eth":"0.42"}]

API reference

format_ether(UINT256) #

Formats a UINT256 wei value using the fixed 18-decimal Ether scale.

Inputs

Name Type Use
wei UINT256

Raw wei amount to display using 18 decimals.

required positional

Returns

Name Type
eth VARCHAR

Ether amount string. Returns a VARCHAR decimal Ether representation without floating point conversion.

Show 1 more signature
format_ether(INT256) #

Formats a signed INT256 wei delta using the fixed 18-decimal Ether scale.

Inputs

Name Type Use
wei INT256

Raw wei amount to display using 18 decimals.

required positional

Returns

Name Type
eth VARCHAR

Ether amount string. Returns a VARCHAR decimal Ether representation without floating point conversion.

Overload examples

Runs locally

SELECT format_ether((-420000000000000000)::INT256) AS eth;

Guidance

Display wei values

format_ether is format_units with decimals fixed at 18. Use it when a raw ETH or WETH balance should be shown to a human.

  • The returned VARCHAR is for display; keep UINT256 wei values for calldata, simulation, and comparisons.
  • Use parse_ether when converting a human ETH string back to wei.

Runs locally

SELECT format_ether(parse_ether('1.25')) AS eth;