zkUseFactoryDep

Signature

function zkUseFactoryDep(string calldata name) external pure;

Description

Marks a given contract as a factory dependency only for the next CREATE or CALL, unmarking it afterwards, similar to prank.

This cheatcode is useful when deploying contracts through factories that do not directly depend on a given contract, as it allows explicitly marking this type of contract as a factory dependency, enabling the factory to deploy the contract. More information on factory dependencies can be found in the official ZKsync docs.

Examples

contract Deployer {
    // Factory does not directly depend on TwoUserMultisig, so we need to mark it explicitly
    // as a factory dependency to allow deployment through the factory
    // Deploy the factory
    Factory factory = new Factory(multisigBytecodeHash);

    // Mark the bytecode as a factory dependency
    vmExt.zkUseFactoryDep("TwoUserMultisig");

    // Deploy the account using the factory
    factory.deployAccount(multisigBytecodeHash);
}