Copy
Ask AI
import { Hex } from '@tevm/voltaire/Hex';
// Create some hex strings
const hex1 = Hex('0x1234');
const hex2 = Hex('0x5678');
const hex3 = Hex('0xabcd');
// Concatenate them (variadic arguments)
const combined = Hex.concat(hex1, hex2, hex3);
console.log('Concatenated:', combined);
// Can also concatenate with bytes converted to hex
const bytes = new Uint8Array([0x01, 0x02, 0x03]);
const hexFromBytes = Hex(bytes);
const withBytes = Hex.concat(hex1, hexFromBytes);
console.log('With bytes:', withBytes);
// Concatenate just two
const twoValues = Hex.concat('0xaa', '0xbb');
console.log('Two values:', twoValues);
This is a fully executable example. View the complete source with test assertions at
examples/hex-and-bytes/hex-concatenate.ts.
