> **Can't find what you're looking for?** Use `search_docs` on the docs MCP server at `https://v3.viem.sh/api/mcp` to find what you need.

# Hex.fromBoolean

:::info
`Hex.fromBoolean` is a re-export of ox's [`Hex.fromBoolean`](https://oxlib.sh/api/Hex/fromBoolean). Refer to the ox documentation for the full reference.
:::

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

## Imports

```ts
import { Hex } from 'viem/utils'
```

## Examples

```ts twoslash
// @noErrors
import { Hex } from 'viem/utils'

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

## 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`](/docs/utilities/hex/types#hex) value.

`Hex`
