Skip to content
LogoLogo

CallParams & CallResult

CallParams

Defined in src/call_params.zig, exposed as Evm.CallParams.

pub union(enum) {
    call: struct {
        caller: Address,
        to: Address,
        value: u256,
        input: []const u8,
        gas: u64,
    },
    callcode: struct {
        caller: Address,
        to: Address,
        value: u256,
        input: []const u8,
        gas: u64,
    },
    delegatecall: struct {
        caller: Address,
        to: Address,
        input: []const u8,
        gas: u64,
    },
    staticcall: struct {
        caller: Address,
        to: Address,
        input: []const u8,
        gas: u64,
    },
    create: struct {
        caller: Address,
        value: u256,
        init_code: []const u8,
        gas: u64,
    },
    create2: struct {
        caller: Address,
        value: u256,
        init_code: []const u8,
        salt: u256,
        gas: u64,
    },
}

Methods & validation

MethodSignatureBehavior
validate / validateForHardforkfn (self) ValidationError!void / fn (self, hardfork) ValidationError!voidEnforces input.len ≤ 4 MiB on call variants (InvalidInputSize) and, at Shanghai or later, init_code.len ≤ config.max_initcode_size (default 49,152; InvalidInitCodeSize, EIP-3860). validate checks against config.hardfork; vm.call() runs validateForHardfork(vm.hardfork).
getGas / setGasu64 / voidReads or updates the gas field on any variant.
getCallerAddressReturns caller.
get_to?AddressReturns to for call variants; null for .create / .create2.
getInput[]const u8Returns input or init_code.
hasValuebooltrue when value > 0 (always false for .delegatecall and .staticcall).
isReadOnlybooltrue for .staticcall.
isCreatebooltrue for .create and .create2.
clone / deinitallocatorDeep-copies and frees the input / init_code slice.

CallResult

Defined in src/call_result.zig, exposed as Evm.CallResult.

pub struct {
    success: bool,
    gas_left: u64,
    output: []const u8,
    refund_counter: u64 = 0,
    logs: []const Log = &.{},
    selfdestructs: []const SelfDestructRecord = &.{},
    accessed_addresses: []const Address = &.{},
    accessed_storage: []const StorageAccess = &.{},
    trace: ?ExecutionTrace = null,
    error_info: ?[]const u8 = null,
    created_address: ?Address = null,
}

Field semantics

FieldValue on RETURN / STOPValue on REVERTValue on CallError
successtruefalsefalse
gas_leftUnspent execution gasUnspent execution gas0
outputReturn bytesRevert payload&.{}
refund_counterRaw refund accumulator00
logsEmitted logs&.{}&.{}
error_infonullnull@errorName(err) (e.g. "OutOfGas")
created_addressDeployed address (for create/create2)nullnull

Helpers & ownership

MethodSemantics
isSuccess() bool / isFailure() boolPredicate wrappers around success.
hasOutput() booloutput.len > 0.
gasConsumed(original_gas: u64) u64original_gas - gas_left (clamped to 0 if gas_left > original_gas).
toOwnedResult(allocator) !CallResultDeep-copies every slice (output, logs, selfdestructs, accessed_*, error_info, trace) into allocator so the result outlives vm.deinit().
deinit(allocator) voidFrees all memory allocated by toOwnedResult() and resets self.* = undefined. Never call on an uncloned result returned directly by vm.call().

Supporting structs

pub const SelfDestructRecord = struct {
    contract: Address,
    beneficiary: Address,
};
 
pub const StorageAccess = struct {
    address: Address,
    slot: u256,
};