# 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.

Canonical HTML: <https://determica.com/docs/functions/parse_gwei>

- Kind: scalar function
- Category: [EVM utilities](/docs/category/evm-utilities.md)
- Tags: Types, EVM

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.

## Overload 1: parse_gwei(VARCHAR)

```sql
parse_gwei(VARCHAR)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (VARCHAR; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 2: parse_gwei(DOUBLE)

```sql
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.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (DOUBLE; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 3: parse_gwei(FLOAT)

```sql
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.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (FLOAT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 4: parse_gwei(TINYINT)

```sql
parse_gwei(TINYINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (TINYINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 5: parse_gwei(SMALLINT)

```sql
parse_gwei(SMALLINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (SMALLINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 6: parse_gwei(INTEGER)

```sql
parse_gwei(INTEGER)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (INTEGER; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 7: parse_gwei(BIGINT)

```sql
parse_gwei(BIGINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (BIGINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 8: parse_gwei(HUGEINT)

```sql
parse_gwei(HUGEINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (HUGEINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 9: parse_gwei(UTINYINT)

```sql
parse_gwei(UTINYINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (UTINYINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 10: parse_gwei(USMALLINT)

```sql
parse_gwei(USMALLINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (USMALLINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 11: parse_gwei(UINTEGER)

```sql
parse_gwei(UINTEGER)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (UINTEGER; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 12: parse_gwei(UBIGINT)

```sql
parse_gwei(UBIGINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (UBIGINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 13: parse_gwei(UHUGEINT)

```sql
parse_gwei(UHUGEINT)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (UHUGEINT; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `wei` (UINT256)

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

## Overload 14: parse_gwei(UINT256)

```sql
parse_gwei(UINT256)
```

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

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `gwei` (UINT256; required; positional) — Use VARCHAR for exact decimal amounts. Non-string numeric overloads are convenience forms.

### Returns

Wei amount

Returns a UINT256 wei amount scaled by 10^9.

- `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.

```sql
SELECT parse_gwei('20') AS gas_price_wei;
```

## Additional examples

```sql
-- Convert a priority-fee input from gwei to wei
SELECT parse_gwei('2.5')::VARCHAR AS wei;
-- => [{"wei":"2500000000"}]
```

## Related functions

- [parse_units](/docs/functions/parse_units.md) — Alternative
- [parse_ether](/docs/functions/parse_ether.md) — See Also
