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

## `envBytes32`

### Signature

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

### Description

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

### Parameters

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

### Returns

| Type        | Description                                    |
|-------------|------------------------------------------------|
| `bytes32`   | The environment variable value as bytes32      |
| `bytes32[]` | The environment variable value as a bytes32 array |

### Examples

#### Single Value

With environment variable `BYTES32_VALUE=0x00`:

```solidity [test/EnvBytes32.t.sol]
string memory key = "BYTES32_VALUE";
bytes32 expected = bytes32(0x0000000000000000000000000000000000000000000000000000000000000000);
bytes32 output = vm.envBytes32(key);
assert(output == expected);
```

#### Array

With environment variable `BYTES32_VALUES=0x7109709ECfa91a80626fF3989D68f67F5b1DD12D,0x00`:

```solidity [test/EnvBytes32.t.sol]
string memory key = "BYTES32_VALUES";
string memory delimiter = ",";
bytes32[2] memory expected = [
    bytes32(0x7109709ECfa91a80626fF3989D68f67F5b1DD12D000000000000000000000000),
    bytes32(0x0000000000000000000000000000000000000000000000000000000000000000)
];
bytes32[] memory output = vm.envBytes32(key, delimiter);
assert(keccak256(abi.encodePacked((output))) == keccak256(abi.encodePacked((expected))));
```

### Related Cheatcodes

- [`envOr`](/reference/cheatcodes/env-or) - Read environment variables with default values
- [`envAddress`](/reference/cheatcodes/env-address) - Read environment variables as address
- [`envBytes`](/reference/cheatcodes/env-bytes) - Read environment variables as bytes
