Skip to main content

build_init_code

Function build_init_code 

Source
pub fn build_init_code(
    creation_code: impl AsRef<[u8]>,
    constructor_args: impl AsRef<[u8]>,
) -> Bytes
Expand description

Build init code from creation bytecode and ABI-encoded constructor args.

Init code is simply the contract’s creation bytecode with the ABI-encoded constructor arguments appended, matching how the EVM expects a CREATE payload to be laid out. The constructor_args must already be ABI encoded; use encode_constructor_args to produce them from an alloy Solidity value tuple.

use evm_fork_cache::deploy::build_init_code;

let init = build_init_code([0x60, 0x80], [0x01, 0x02, 0x03]);
assert_eq!(init.as_ref(), &[0x60, 0x80, 0x01, 0x02, 0x03]);