[**@tevm/utils**](../README.md) *** [@tevm/utils](../globals.md) / boolToHex # Function: boolToHex() > **boolToHex**(`value`, `opts?`): `` `0x${string}` `` Defined in: node\_modules/.pnpm/viem@2.49.3\_bufferutil@4.1.0\_typescript@6.0.3\_utf-8-validate@5.0.10\_zod@4.4.3/node\_modules/viem/\_types/utils/encoding/toHex.d.ts:66 Encodes a boolean into a hex string - Docs: https://viem.sh/docs/utilities/toHex#booltohex ## Parameters | Parameter | Type | Description | | ------ | ------ | ------ | | `value` | `boolean` | Value to encode. | | `opts?` | `BoolToHexOpts` | Options. | ## Returns `` `0x${string}` `` Hex value. ## Examples ```ts import { boolToHex } from 'viem' const data = boolToHex(true) // '0x1' ``` ```ts import { boolToHex } from 'viem' const data = boolToHex(false) // '0x0' ``` ```ts import { boolToHex } from 'viem' const data = boolToHex(true, { size: 32 }) // '0x0000000000000000000000000000000000000000000000000000000000000001' ```