bytesToHex
bytesToHex(
value
,opts
?):Hex
Encodes a bytes array into a hex string
Parameters
• value: Uint8Array
Value to encode.
• opts?: BytesToHexOpts
Options.
Returns
Hex value.
Examples
import { bytesToHex } from 'viem'const data = bytesToHex(Uint8Array.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])// '0x48656c6c6f20576f726c6421'
import { bytesToHex } from 'viem'const data = bytesToHex(Uint8Array.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]), { size: 32 })// '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000'
Defined in
node_modules/.pnpm/viem@2.14.2_bufferutil@4.0.8_typescript@5.5.4_utf-8-validate@6.0.4_zod@3.23.8/node_modules/viem/_types/utils/encoding/toHex.d.ts:91