## `envInt`

### Signature

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

### Description

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

### Parameters

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

### Returns

| Type       | Description                                    |
|------------|------------------------------------------------|
| `int256`   | The environment variable value as a signed integer |
| `int256[]` | The environment variable value as a signed integer array |

### Examples

#### Single Value

With environment variable `INT_VALUE=-57896044618658097711785492504343953926634992332820282019728792003956564819968`:

```solidity [test/EnvInt.t.sol]
string memory key = "INT_VALUE";
int256 expected = type(int256).min;
int256 output = vm.envInt(key);
assert(output == expected);
```

#### Array

With environment variable `INT_VALUES=-0x8000000000000000000000000000000000000000000000000000000000000000,+0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF`:

```solidity [test/EnvInt.t.sol]
string memory key = "INT_VALUES";
string memory delimiter = ",";
int256[2] memory expected = [type(int256).min, type(int256).max];
int256[] memory output = vm.envInt(key, delimiter);
assert(keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked((expected))));
```

### Gotchas

:::note
If the value starts with `0x`, `-0x`, or `+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
* [`envUint`](/reference/cheatcodes/env-uint) - Read environment variables as unsigned integers
* [`envString`](/reference/cheatcodes/env-string) - Read environment variables as string
