Skip to content

boolToHex

boolToHex(value, opts?): Hex

Encodes a boolean into a hex string

Parameters

value: boolean

Value to encode.

opts?: BoolToHexOpts

Options.

Returns

Hex

Hex value.

Examples

import { boolToHex } from 'viem'
const data = boolToHex(true)
// '0x1'
import { boolToHex } from 'viem'
const data = boolToHex(false)
// '0x0'
import { boolToHex } from 'viem'
const data = boolToHex(true, { size: 32 })
// '0x0000000000000000000000000000000000000000000000000000000000000001'

Defined in

node_modules/.pnpm/viem@2.14.2_bufferutil@4.0.8_typescript@5.5.2_utf-8-validate@6.0.4_zod@3.23.8/node_modules/viem/_types/utils/encoding/toHex.d.ts:66