Hex & Bytes
Hex Encoding and Decoding
Convert between hex strings and byte arrays using Voltaire’s Hex primitive
Convert between hex strings and byte arrays using Voltaire’s Hex primitive
Was this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Convert between hex strings and byte arrays using Voltaire’s Hex primitive
import { Bytes } from '@tevm/voltaire/Bytes';
import * as Hex from '@tevm/voltaire/Hex';
// Encode bytes to hex string
const bytes = Bytes.from([72, 101, 108, 108, 111]); // "Hello" in bytes
const hexString = Hex.fromBytes(bytes);
// Decode hex string back to bytes
const decoded = Hex.toBytes(hexString);
// Create hex directly from string
const directHex = Hex.from("0x48656c6c6f");
examples/hex-and-bytes/hex-encode-decode.ts.Was this page helpful?
