parse_gwei

Shorthand for parse_units(value, 9). Converts gwei 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 priority-fee input from gwei to wei
2
SELECT parse_gwei('2.5')::VARCHAR AS wei;
3
-- => [{"wei":"2500000000"}]
Notebook ready in readonly mode.

API reference

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

parse_gwei(VARCHAR) #

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

Inputs

Name Type Use
gwei 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^9.

Guidance

Gas price units

parse_gwei is parse_units with decimals fixed at 9. Use it when a gas price or fee input is expressed in gwei but downstream EVM fields require wei.

  • Use parse_gwei('20') for exact decimal parsing.
  • Use parse_units(value, 18) or parse_ether when the input is ETH rather than gwei.
  • Do not pass FLOAT or DOUBLE values for capital-moving fee amounts.

Local SQL

1
SELECT parse_gwei('20') AS gas_price_wei;
Notebook ready in readonly mode.

Additional overloads

Show 13 more overloads
parse_gwei(DOUBLE) #

Parses a non-negative gwei value of type DOUBLE to wei using the fixed 9-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
gwei 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^9.

parse_gwei(FLOAT) #

Parses a non-negative gwei value of type FLOAT to wei using the fixed 9-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
gwei 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^9.

parse_gwei(TINYINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(SMALLINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(INTEGER) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(BIGINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(HUGEINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(UTINYINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(USMALLINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(UINTEGER) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(UBIGINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(UHUGEINT) #

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

Inputs

Name Type Use
gwei 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^9.

parse_gwei(UINT256) #

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

Inputs

Name Type Use
gwei 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^9.

Related functions

Category and tags

Category
EVM utilities
Tag
Types
Tag
EVM