@tevm/voltaire / primitives/CallData
primitives/CallData
Classes
InvalidCallDataLengthError
Defined in: src/primitives/CallData/errors.ts:4 Error thrown when calldata is too short (must be at least 4 bytes for selector)Extends
Error
Constructors
Constructor
new InvalidCallDataLengthError(Defined in: src/primitives/CallData/errors.ts:9message,options?):InvalidCallDataLengthError
Parameters
message
string
options?
expected?
string
value?
unknown
Returns
InvalidCallDataLengthError
Overrides
Error.constructor
Properties
code
Defined in: src/primitives/CallData/errors.ts:5readonlycode:"INVALID_CALLDATA_LENGTH"="INVALID_CALLDATA_LENGTH"
expected
Defined in: src/primitives/CallData/errors.ts:7readonlyexpected:string
value
Defined in: src/primitives/CallData/errors.ts:6readonlyvalue:unknown
InvalidHexFormatError
Defined in: src/primitives/CallData/errors.ts:23 Error thrown when hex string format is invalidExtends
Error
Constructors
Constructor
new InvalidHexFormatError(Defined in: src/primitives/CallData/errors.ts:26message):InvalidHexFormatError
Parameters
message
string
Returns
InvalidHexFormatError
Overrides
Error.constructor
Properties
code
Defined in: src/primitives/CallData/errors.ts:24readonlycode:"INVALID_HEX_FORMAT"="INVALID_HEX_FORMAT"
InvalidValueError
Defined in: src/primitives/CallData/errors.ts:35 Error thrown when value type is unsupportedExtends
Error
Constructors
Constructor
new InvalidValueError(Defined in: src/primitives/CallData/errors.ts:40message,options?):InvalidValueError
Parameters
message
string
options?
expected?
string
value?
unknown
Returns
InvalidValueError
Overrides
Error.constructor
Properties
code
Defined in: src/primitives/CallData/errors.ts:36readonlycode:"INVALID_VALUE"="INVALID_VALUE"
expected?
Defined in: src/primitives/CallData/errors.ts:38readonlyoptionalexpected:string
value
Defined in: src/primitives/CallData/errors.ts:37readonlyvalue:unknown
Interfaces
BaseCallData
Defined in: src/primitives/CallData/index.ts:12 Base CallData interface with instance methodsExtends
Indexable
[index: number]: number
Properties
[brand]
Defined in: src/primitives/CallData/CallDataType.ts:10readonly[brand]:"CallData"
Inherited from
CallDataType.[brand]
Methods
equals()
equals(Defined in: src/primitives/CallData/index.ts:17other):boolean
Parameters
other
CallDataType
Returns
boolean
getSelector()
getSelector(): Uint8Array
Defined in: src/primitives/CallData/index.ts:15
Returns
Uint8Array
hasSelector()
hasSelector(Defined in: src/primitives/CallData/index.ts:16selector):boolean
Parameters
selector
string | Uint8Array<ArrayBufferLike>
Returns
boolean
toBytes()
toBytes(): Uint8Array
Defined in: src/primitives/CallData/index.ts:14
Returns
Uint8Array
toHex()
toHex(): string
Defined in: src/primitives/CallData/index.ts:13
Convert the Uint8Array to a hex encoded string
Returns
string
The hex encoded string representation of the Uint8Array
Overrides
CallDataType.toHex
Type Aliases
CallDataType
CallDataType =Defined in: src/primitives/CallData/CallDataType.ts:9 Branded CallData type for EVM transaction calldata CallData is a branded Uint8Array containing function selector (first 4 bytes) followed by ABI-encoded parameters.Uint8Array&object
Type Declaration
[brand]
readonly[brand]:"CallData"
Variables
decode()
Defined in: src/primitives/CallData/index.ts:118 Decode CallData to structured formconstdecode: (calldata,abi) =>CallDataDecoded=BrandedCallData.decode
Parameters
calldata
CallDataType
CallData to decode
abi
readonlyItem[]
ABI specification with function definitions
Returns
CallDataDecoded
Decoded structure with selector, signature, and parameters
Throws
If function not found in ABI or decoding failsExample
encode()
Defined in: src/primitives/CallData/index.ts:117constencode: (signature,params) =>CallDataType=CallData.encode
Parameters
signature
string
params
unknown[]
Returns
CallDataType
equals()
Defined in: src/primitives/CallData/index.ts:114 Check if two CallData instances are equal (constant-time comparison) Uses constant-time comparison to prevent timing attacks.constequals: (a,b) =>boolean=BrandedCallData.equals
Parameters
a
CallDataType
First CallData
b
CallDataType
Second CallData
Returns
boolean
True if instances are bytewise identical
Example
from()
Defined in: src/primitives/CallData/index.ts:107constfrom: (value) =>CallDataType=CallData.from
Parameters
value
string | Uint8Array<ArrayBufferLike>
Returns
CallDataType
fromBytes()
Defined in: src/primitives/CallData/index.ts:109constfromBytes: (value) =>CallDataType=CallData.fromBytes
Parameters
value
Uint8Array
Returns
CallDataType
fromHex()
Defined in: src/primitives/CallData/index.ts:108constfromHex: (value) =>CallDataType=CallData.fromHex
Parameters
value
string
Returns
CallDataType
getSelector()
Defined in: src/primitives/CallData/index.ts:112 Extract 4-byte function selector from CallDataconstgetSelector: (calldata) =>Uint8Array<ArrayBufferLike> =BrandedCallData.getSelector
Parameters
calldata
CallDataType
CallData to extract selector from
Returns
Uint8Array<ArrayBufferLike>
4-byte array containing function selector (view, not copy)
Example
hasSelector()
Defined in: src/primitives/CallData/index.ts:113 Check if CallData matches a specific function selector Uses constant-time comparison to prevent timing attacks.consthasSelector: (calldata,selector) =>boolean=BrandedCallData.hasSelector
Parameters
calldata
CallDataType
CallData to check
selector
Expected selector (hex string or bytes)string | Uint8Array<ArrayBufferLike>
Returns
boolean
True if selector matches
Example
is()
Defined in: src/primitives/CallData/index.ts:115 Type guard to check if value is CallDataconstis: (value) =>value is CallDataType=BrandedCallData.is
Parameters
value
unknown
Value to check
Returns
value is CallDataType
True if value is CallData
Example
isValid()
Defined in: src/primitives/CallData/index.ts:116 Check if value can be converted to CallDataconstisValid: (value) =>boolean=BrandedCallData.isValid
Parameters
value
unknown
Value to validate
Returns
boolean
True if value can be converted to CallData
Example
MIN_SIZE
Defined in: src/primitives/CallData/constants.js:5 Minimum size for calldata (4 bytes for function selector)constMIN_SIZE:number=4
SELECTOR_SIZE
Defined in: src/primitives/CallData/constants.js:11 Size of function selector in bytesconstSELECTOR_SIZE:number=4
toBytes()
Defined in: src/primitives/CallData/index.ts:111 Return the underlying Uint8Array representation (zero-copy)consttoBytes: (calldata) =>Uint8Array<ArrayBufferLike> =BrandedCallData.toBytes
Parameters
calldata
CallDataType
CallData to convert
Returns
Uint8Array<ArrayBufferLike>
Raw byte array (shares underlying buffer)
Example
toHex()
Defined in: src/primitives/CallData/index.ts:110 Convert CallData to hex string with 0x prefixconsttoHex: (calldata) =>HexType=BrandedCallData.toHex
Parameters
calldata
CallDataType
CallData to convert
Returns
HexType
Lowercase hex string with 0x prefix
Example
Functions
CallData()
CallData(Defined in: src/primitives/CallData/index.ts:35 Creates CallData instances with prototype chainvalue):BaseCallData
Parameters
value
Value to convert (hex string or bytes)string | Uint8Array<ArrayBufferLike>
Returns
BaseCallData
CallData instance with prototype methods

