> **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.

# Bytes.fromBoolean

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

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

## Imports

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

## Examples

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

const data = Bytes.fromBoolean(true)
// @log: Uint8Array([1])
```

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

const data = Bytes.fromBoolean(true, { size: 32 })
// @log: Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
```

## Definition

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

## Parameters

### value

* **Type:** `boolean`

Boolean value to encode.

### options

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

Encoding options.

#### options.size

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

Size of the output bytes.

## Return Type

Encoded [`Bytes.Bytes`](/docs/utilities/bytes/types#bytes).

`Uint8Array`
