# Hex.fromBoolean

Encodes a boolean into a [`Hex.Hex`](/api/Hex/types#hex) value.

## Imports

:::code-group
```ts [Named]
import { Hex } from 'ox'
```

```ts [Entrypoint]
import * as Hex from 'ox/Hex'
```
:::

## Examples

```ts twoslash
import { Hex } from 'ox'

Hex.fromBoolean(true)
// @log: '0x1'

Hex.fromBoolean(false)
// @log: '0x0'

Hex.fromBoolean(true, { size: 32 })
// @log: '0x0000000000000000000000000000000000000000000000000000000000000001'
```

## Definition

```ts
function fromBoolean(
  value: boolean,
  options?: fromBoolean.Options,
): Hex
```

**Source:** [src/core/Hex.ts](https://github.com/wevm/ox/blob/main/src/core/Hex.ts#L1003)

## Parameters

### value

* **Type:** `boolean`

The boolean value to encode.

### options

* **Type:** `fromBoolean.Options`
* **Optional**

Options.

#### options.size

* **Type:** `number`
* **Optional**

The size (in bytes) of the output hex value.

## Return Type

The encoded [`Hex.Hex`](/api/Hex/types#hex) value.

`Hex`
