parse_ether

Shorthand for parse_units(value, 18). Converts ETH/WETH amounts to wei. Prefer VARCHAR inputs for capital-moving amounts. Negative values and excess fractional precision are rejected; overflow currently follows parse_units compatibility behavior and wraps modulo 2^256.

Example

Local

1
-- Convert a human ETH amount to wei without floating point
2
SELECT parse_ether('0.42')::VARCHAR AS wei;
3
-- => [{"wei":"420000000000000000"}]
Notebook ready in readonly mode.

API reference

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

parse_ether(VARCHAR) #

Parses a non-negative ETH value of type VARCHAR to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth VARCHAR

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

Guidance

ETH and WETH input

parse_ether is parse_units with decimals fixed at 18. It is intended for human ETH amounts before building calldata, simulation value fields, or balance comparisons.

  • Use parse_ether('1.25') for exact decimal parsing.
  • Use format_ether when converting raw wei back to a display string.
  • Do not pass FLOAT or DOUBLE values for capital-moving ETH amounts.

Local SQL

1
SELECT parse_ether('1.25') AS wei;
Notebook ready in readonly mode.

Additional overloads

Show 13 more overloads
parse_ether(DOUBLE) #

Parses a non-negative ETH value of type DOUBLE to wei using the fixed 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
eth DOUBLE

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(FLOAT) #

Parses a non-negative ETH value of type FLOAT to wei using the fixed 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
eth FLOAT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(TINYINT) #

Parses a non-negative ETH value of type TINYINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth TINYINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(SMALLINT) #

Parses a non-negative ETH value of type SMALLINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth SMALLINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(INTEGER) #

Parses a non-negative ETH value of type INTEGER to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth INTEGER

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(BIGINT) #

Parses a non-negative ETH value of type BIGINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth BIGINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(HUGEINT) #

Parses a non-negative ETH value of type HUGEINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth HUGEINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(UTINYINT) #

Parses a non-negative ETH value of type UTINYINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth UTINYINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(USMALLINT) #

Parses a non-negative ETH value of type USMALLINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth USMALLINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(UINTEGER) #

Parses a non-negative ETH value of type UINTEGER to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth UINTEGER

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(UBIGINT) #

Parses a non-negative ETH value of type UBIGINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth UBIGINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(UHUGEINT) #

Parses a non-negative ETH value of type UHUGEINT to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth UHUGEINT

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

parse_ether(UINT256) #

Parses a non-negative ETH value of type UINT256 to wei using the fixed 18-decimal scale.

Inputs

Name Type Use
eth UINT256

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

required positional

Returns

Name Type
wei UINT256

Wei amount. Returns a UINT256 wei amount scaled by 10^18.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM