---
description: Reads an environment variable as uint256 or uint256[]
---

## `envUint`

### Signature

```solidity
function envUint(string calldata key) external returns (uint256 value);
function envUint(string calldata key, string calldata delimiter) external returns (uint256[] memory values);
```

### Description

Reads an environment variable as `uint256` or `uint256[]`.

### Parameters

| Parameter   | Type     | Description                               |
|-------------|----------|-------------------------------------------|
| `key`       | `string` | The environment variable name             |
| `delimiter` | `string` | The delimiter used to separate array values (optional) |

### Returns

| Type        | Description                                       |
|-------------|---------------------------------------------------|
| `uint256`   | The environment variable value as an unsigned integer |
| `uint256[]` | The environment variable value as an unsigned integer array |

### Examples

#### Single Value

With environment variable `UINT_VALUE=115792089237316195423570985008687907853269984665640564039457584007913129639935`:

```solidity [test/EnvUint.t.sol]
string memory key = "UINT_VALUE";
uint256 expected = type(uint256).max;
uint256 output = vm.envUint(key);
assert(output == expected);
```

#### Array

With environment variable `UINT_VALUES=0,0x0000000000000000000000000000000000000000000000000000000000000000`:

```solidity [test/EnvUint.t.sol]
string memory key = "UINT_VALUES";
string memory delimiter = ",";
uint256[2] memory expected = [type(uint256).min, type(uint256).min];
uint256[] memory output = vm.envUint(key, delimiter);
assert(keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked((expected))));
```

### Gotchas

:::note
If the value starts with `0x`, it will be interpreted as a hex value. Otherwise, it will be treated as a decimal number.
:::

### Related Cheatcodes

- [`envOr`](/reference/cheatcodes/env-or) - Read environment variables with default values
- [`envInt`](/reference/cheatcodes/env-int) - Read environment variables as signed integers
- [`envString`](/reference/cheatcodes/env-string) - Read environment variables as string
