Skip to main content
Creates CallData from a hex-encoded string. Specialized constructor for hex input with explicit validation.

Signature

Parameters

  • hex - Hex-encoded string (with or without 0x prefix)

Returns

CallDataType - Branded Uint8Array representing transaction calldata

Examples

Validation

Validates hex string format:

Comparison with from()

fromHex is more explicit but less flexible than from:
Use fromHex when:
  • Input is always hex string
  • You want explicit type checking
  • Code clarity is prioritized
Use from when:
  • Input type varies
  • Maximum flexibility needed
  • Writing generic functions

Use Cases

Parse Raw Transaction

Validate Hex Input

Type-Safe API