parse_units

Converts human-readable token amounts to UINT256 raw values by multiplying by 10^decimals. Prefer VARCHAR inputs for capital-moving amounts. Negative values are rejected, fractional digits beyond decimals are rejected, and decimals must be between 0 and 77. String inputs trim surrounding whitespace, allow an optional leading plus sign, right-pad fractional digits with zeros, accept trailing fractional zeros, and reject scientific notation. Values that exceed UINT256 currently wrap modulo 2^256; treat that as compatibility behavior and validate untrusted amounts before parsing.

Example

Local

1
-- Convert an exact human USDC amount to its 6-decimal onchain integer
2
SELECT parse_units('12.345678', 6)::VARCHAR AS raw_usdc;
3
-- => [{"raw_usdc":"12345678"}]
Notebook ready in readonly mode.

API reference

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

parse_units(VARCHAR) #

Parses a non-negative token amount of type VARCHAR using the default 18-decimal scale.

Inputs

Name Type Use
value VARCHAR

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

Guidance

Raw units vs display strings

Use string literals for token amounts that may move value. The string parser is decimal-exact and rejects scientific notation, negative values, and excess fractional precision.

  • Use parse_units('2500', 6) for 2,500 USDC-style tokens.
  • Use parse_ether for ETH and WETH amounts with the fixed 18-decimal scale.
  • Use format_units or format_ether when you need display strings from raw integer balances.
  • Do not pass FLOAT or DOUBLE values for capital-moving token amounts; those overloads are convenience-only and inherit floating point ambiguity before conversion.

Local SQL

1
SELECT
2
parse_units('2500', 6) AS raw_usdc,
3
parse_ether('1.25') AS raw_eth;
Notebook ready in readonly mode.

Additional overloads

parse_units(VARCHAR, INTEGER) #

Parses a non-negative token amount of type VARCHAR using a decimal scale of type INTEGER.

Inputs

Name Type Use
value VARCHAR

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

Show 54 more overloads
parse_units(VARCHAR, UTINYINT) #

Parses a non-negative token amount of type VARCHAR using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value VARCHAR

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(VARCHAR, UINT8) #

Parses a non-negative token amount of type VARCHAR using a decimal scale of type UINT8.

Inputs

Name Type Use
value VARCHAR

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(DOUBLE) #

Parses a non-negative token amount of type DOUBLE using the default 18-decimal scale. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value DOUBLE

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(DOUBLE, INTEGER) #

Parses a non-negative token amount of type DOUBLE using a decimal scale of type INTEGER. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value DOUBLE

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(DOUBLE, UTINYINT) #

Parses a non-negative token amount of type DOUBLE using a decimal scale of type UTINYINT. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value DOUBLE

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(DOUBLE, UINT8) #

Parses a non-negative token amount of type DOUBLE using a decimal scale of type UINT8. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value DOUBLE

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(FLOAT) #

Parses a non-negative token amount of type FLOAT using the default 18-decimal scale. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value FLOAT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(FLOAT, INTEGER) #

Parses a non-negative token amount of type FLOAT using a decimal scale of type INTEGER. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value FLOAT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(FLOAT, UTINYINT) #

Parses a non-negative token amount of type FLOAT using a decimal scale of type UTINYINT. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value FLOAT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(FLOAT, UINT8) #

Parses a non-negative token amount of type FLOAT using a decimal scale of type UINT8. Prefer VARCHAR inputs for capital-moving amounts. FLOAT and DOUBLE overloads are convenience forms and can introduce floating point ambiguity before conversion to UINT256.

Inputs

Name Type Use
value FLOAT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(TINYINT) #

Parses a non-negative token amount of type TINYINT using the default 18-decimal scale.

Inputs

Name Type Use
value TINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(TINYINT, INTEGER) #

Parses a non-negative token amount of type TINYINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value TINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(TINYINT, UTINYINT) #

Parses a non-negative token amount of type TINYINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value TINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(TINYINT, UINT8) #

Parses a non-negative token amount of type TINYINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value TINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(SMALLINT) #

Parses a non-negative token amount of type SMALLINT using the default 18-decimal scale.

Inputs

Name Type Use
value SMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(SMALLINT, INTEGER) #

Parses a non-negative token amount of type SMALLINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value SMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(SMALLINT, UTINYINT) #

Parses a non-negative token amount of type SMALLINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value SMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(SMALLINT, UINT8) #

Parses a non-negative token amount of type SMALLINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value SMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(INTEGER) #

Parses a non-negative token amount of type INTEGER using the default 18-decimal scale.

Inputs

Name Type Use
value INTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(INTEGER, INTEGER) #

Parses a non-negative token amount of type INTEGER using a decimal scale of type INTEGER.

Inputs

Name Type Use
value INTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(INTEGER, UTINYINT) #

Parses a non-negative token amount of type INTEGER using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value INTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(INTEGER, UINT8) #

Parses a non-negative token amount of type INTEGER using a decimal scale of type UINT8.

Inputs

Name Type Use
value INTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(BIGINT) #

Parses a non-negative token amount of type BIGINT using the default 18-decimal scale.

Inputs

Name Type Use
value BIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(BIGINT, INTEGER) #

Parses a non-negative token amount of type BIGINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value BIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(BIGINT, UTINYINT) #

Parses a non-negative token amount of type BIGINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value BIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(BIGINT, UINT8) #

Parses a non-negative token amount of type BIGINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value BIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(HUGEINT) #

Parses a non-negative token amount of type HUGEINT using the default 18-decimal scale.

Inputs

Name Type Use
value HUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(HUGEINT, INTEGER) #

Parses a non-negative token amount of type HUGEINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value HUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(HUGEINT, UTINYINT) #

Parses a non-negative token amount of type HUGEINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value HUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(HUGEINT, UINT8) #

Parses a non-negative token amount of type HUGEINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value HUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UTINYINT) #

Parses a non-negative token amount of type UTINYINT using the default 18-decimal scale.

Inputs

Name Type Use
value UTINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UTINYINT, INTEGER) #

Parses a non-negative token amount of type UTINYINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value UTINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UTINYINT, UTINYINT) #

Parses a non-negative token amount of type UTINYINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value UTINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UTINYINT, UINT8) #

Parses a non-negative token amount of type UTINYINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value UTINYINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(USMALLINT) #

Parses a non-negative token amount of type USMALLINT using the default 18-decimal scale.

Inputs

Name Type Use
value USMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(USMALLINT, INTEGER) #

Parses a non-negative token amount of type USMALLINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value USMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(USMALLINT, UTINYINT) #

Parses a non-negative token amount of type USMALLINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value USMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(USMALLINT, UINT8) #

Parses a non-negative token amount of type USMALLINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value USMALLINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINTEGER) #

Parses a non-negative token amount of type UINTEGER using the default 18-decimal scale.

Inputs

Name Type Use
value UINTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINTEGER, INTEGER) #

Parses a non-negative token amount of type UINTEGER using a decimal scale of type INTEGER.

Inputs

Name Type Use
value UINTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINTEGER, UTINYINT) #

Parses a non-negative token amount of type UINTEGER using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value UINTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINTEGER, UINT8) #

Parses a non-negative token amount of type UINTEGER using a decimal scale of type UINT8.

Inputs

Name Type Use
value UINTEGER

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UBIGINT) #

Parses a non-negative token amount of type UBIGINT using the default 18-decimal scale.

Inputs

Name Type Use
value UBIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UBIGINT, INTEGER) #

Parses a non-negative token amount of type UBIGINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value UBIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UBIGINT, UTINYINT) #

Parses a non-negative token amount of type UBIGINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value UBIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UBIGINT, UINT8) #

Parses a non-negative token amount of type UBIGINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value UBIGINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UHUGEINT) #

Parses a non-negative token amount of type UHUGEINT using the default 18-decimal scale.

Inputs

Name Type Use
value UHUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UHUGEINT, INTEGER) #

Parses a non-negative token amount of type UHUGEINT using a decimal scale of type INTEGER.

Inputs

Name Type Use
value UHUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UHUGEINT, UTINYINT) #

Parses a non-negative token amount of type UHUGEINT using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value UHUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UHUGEINT, UINT8) #

Parses a non-negative token amount of type UHUGEINT using a decimal scale of type UINT8.

Inputs

Name Type Use
value UHUGEINT

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINT256) #

Parses a non-negative token amount of type UINT256 using the default 18-decimal scale.

Inputs

Name Type Use
value UINT256

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINT256, INTEGER) #

Parses a non-negative token amount of type UINT256 using a decimal scale of type INTEGER.

Inputs

Name Type Use
value UINT256

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals INTEGER

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINT256, UTINYINT) #

Parses a non-negative token amount of type UINT256 using a decimal scale of type UTINYINT.

Inputs

Name Type Use
value UINT256

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UTINYINT

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

parse_units(UINT256, UINT8) #

Parses a non-negative token amount of type UINT256 using a decimal scale of type UINT8.

Inputs

Name Type Use
value UINT256

Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

required positional
decimals UINT8

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

required positional

Returns

Name Type
raw_amount UINT256

Raw token units. Returns a UINT256 integer amount scaled by 10^decimals, suitable for ERC-20 calldata and simulations.

Examples

Local SQL

1
-- Decimal strings preserve digits that a binary DOUBLE cannot represent exactly
2
SELECT
3
parse_units('0.100000000000000001', 18)::VARCHAR AS exact_string,
4
parse_units(0.100000000000000001::DOUBLE, 18)::VARCHAR AS floating_input;
5
-- => [{"exact_string":"100000000000000001","floating_input":"100000000000000006"}]
Notebook ready in readonly mode.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM