2

I have the following deploy method:

function deploy(address admin, uint256 _salt, Type _type) public {
    bytes32 salt = keccak256(abi.encodePacked(bytes32(_salt), admin));
    address myContract;
    if (_type == Type.A) {
        myContract = address(new A{salt: salt}());
    } else if (_type == Type.B) {
        myContract = address(new B{salt: salt}());
    }
}

How do I call the contract with Foundry's cast?

1 Answer 1

1

In Solidity, enums are represented by uint8.

Off the top of my head, I would use the following

cast send <contract_address> "deploy(address,uint256,uint8)" 0x3eC11316a0a436ed1BD5943481B3722D2fA4C2a4 2 1 --rpc-url=<rpc_url> --private-key=<private_key>

whereby, 0x3eC11316a0a436ed1BD5943481B3722D2fA4C2a4 is an example for your address, 2 is an example for your uint256 and 1 is an example for your enum parameter. Given your enum holds at least two fields, e.g. Type.A and Type.B, whereby, Type.A is passed via 0 and Type.B via 1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.