format_units

Scales raw EVM integer balances by 10^decimals and returns a VARCHAR string representation. No floating point conversion is introduced. The default decimal scale is 18. INT256 inputs preserve signed values, and trailing fractional zeros are trimmed from the formatted string.

Example

Local

1
-- Display a raw 6-decimal USDC balance
2
SELECT format_units(12345678::UINT256, 6) AS usdc;
3
-- => [{"usdc":"12.345678"}]
Notebook ready in readonly mode.

API reference

Exact signatures with descriptions, requirements, inputs, returns, and examples.

format_units(UINT256) #

Formats a raw amount of type UINT256 using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount UINT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

Guidance

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

1
SELECT
2
format_units(parse_units('2500', 6), 6) AS usdc,
3
format_ether(parse_ether('1.25')) AS eth;
Notebook ready in readonly mode.

Additional overloads

format_units(UINT256, INTEGER) #

Formats a raw amount of type UINT256 using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount UINT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

Show 46 more overloads
format_units(UINT256, UTINYINT) #

Formats a raw amount of type UINT256 using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount UINT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UINT256, UINT8) #

Formats a raw amount of type UINT256 using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount UINT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INT256) #

Formats a raw amount of type INT256 using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount INT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INT256, INTEGER) #

Formats a raw amount of type INT256 using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount INT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INT256, UTINYINT) #

Formats a raw amount of type INT256 using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount INT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INT256, UINT8) #

Formats a raw amount of type INT256 using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount INT256

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UTINYINT) #

Formats a raw amount of type UTINYINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount UTINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UTINYINT, INTEGER) #

Formats a raw amount of type UTINYINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount UTINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UTINYINT, UTINYINT) #

Formats a raw amount of type UTINYINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount UTINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UTINYINT, UINT8) #

Formats a raw amount of type UTINYINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount UTINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(USMALLINT) #

Formats a raw amount of type USMALLINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount USMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(USMALLINT, INTEGER) #

Formats a raw amount of type USMALLINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount USMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(USMALLINT, UTINYINT) #

Formats a raw amount of type USMALLINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount USMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(USMALLINT, UINT8) #

Formats a raw amount of type USMALLINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount USMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UINTEGER) #

Formats a raw amount of type UINTEGER using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount UINTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UINTEGER, INTEGER) #

Formats a raw amount of type UINTEGER using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount UINTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UINTEGER, UTINYINT) #

Formats a raw amount of type UINTEGER using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount UINTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UINTEGER, UINT8) #

Formats a raw amount of type UINTEGER using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount UINTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UBIGINT) #

Formats a raw amount of type UBIGINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount UBIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UBIGINT, INTEGER) #

Formats a raw amount of type UBIGINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount UBIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UBIGINT, UTINYINT) #

Formats a raw amount of type UBIGINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount UBIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UBIGINT, UINT8) #

Formats a raw amount of type UBIGINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount UBIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UHUGEINT) #

Formats a raw amount of type UHUGEINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount UHUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UHUGEINT, INTEGER) #

Formats a raw amount of type UHUGEINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount UHUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UHUGEINT, UTINYINT) #

Formats a raw amount of type UHUGEINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount UHUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(UHUGEINT, UINT8) #

Formats a raw amount of type UHUGEINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount UHUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(TINYINT) #

Formats a raw amount of type TINYINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount TINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(TINYINT, INTEGER) #

Formats a raw amount of type TINYINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount TINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(TINYINT, UTINYINT) #

Formats a raw amount of type TINYINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount TINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(TINYINT, UINT8) #

Formats a raw amount of type TINYINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount TINYINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(SMALLINT) #

Formats a raw amount of type SMALLINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount SMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(SMALLINT, INTEGER) #

Formats a raw amount of type SMALLINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount SMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(SMALLINT, UTINYINT) #

Formats a raw amount of type SMALLINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount SMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(SMALLINT, UINT8) #

Formats a raw amount of type SMALLINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount SMALLINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INTEGER) #

Formats a raw amount of type INTEGER using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount INTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INTEGER, INTEGER) #

Formats a raw amount of type INTEGER using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount INTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INTEGER, UTINYINT) #

Formats a raw amount of type INTEGER using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount INTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(INTEGER, UINT8) #

Formats a raw amount of type INTEGER using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount INTEGER

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(BIGINT) #

Formats a raw amount of type BIGINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount BIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(BIGINT, INTEGER) #

Formats a raw amount of type BIGINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount BIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(BIGINT, UTINYINT) #

Formats a raw amount of type BIGINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount BIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(BIGINT, UINT8) #

Formats a raw amount of type BIGINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount BIGINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(HUGEINT) #

Formats a raw amount of type HUGEINT using the default 18-decimal scale.

Inputs

Name Type Use
raw_amount HUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(HUGEINT, INTEGER) #

Formats a raw amount of type HUGEINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
raw_amount HUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals INTEGER

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(HUGEINT, UTINYINT) #

Formats a raw amount of type HUGEINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
raw_amount HUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UTINYINT

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

format_units(HUGEINT, UINT8) #

Formats a raw amount of type HUGEINT using a decimal scale of type UINT8.

Inputs

Name Type Use
raw_amount HUGEINT

Raw EVM integer units to display. Keep this as an integer type, not FLOAT or DOUBLE.

required positional
decimals UINT8

Decimal precision used by the token contract. Must be an integer between 0 and 77.

required positional

Returns

Name Type
formatted_value VARCHAR

Human-readable decimal string. Returns a VARCHAR decimal representation without converting through FLOAT or DOUBLE.

Examples

Local SQL

1
-- Preserve the sign of a raw 6-decimal accounting delta
2
SELECT format_units((-1234567)::INT256, 6) AS pnl_usdc;
3
-- => [{"pnl_usdc":"-1.234567"}]
Notebook ready in readonly mode.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM