Cannot find option to do multiple chain deployment with Foundry using Defender V2 Deploy

I have to deploy simple contracts on multiple chains at the same address. I want to use Defender Deploy to do this through a MultiSig wallet. I followed the instructions given in the documentation but I am only able to deploy on one chain at a time and also the code is not getting verified.

:computer: Environment

I am using foundry to write deployment scripts, I have setup 5 networks which I want to deploy on in Defender V2 deploy interface.

I can see in the given examples that I have to specify an rpc of one of the networks that I want to deploy on, what do we do for deploying on multiple chains?

:1234: Code to reproduce

contract DefenderScript is Script {
    function setUp() public {}

    function run() public {
        DefenderOptions memory opts;
        opts.useDefenderDeploy = true;
        opts.salt = bytes32(uint256(10));

        address proxy =
            Defender.deployContract("CallBreaker.sol", opts);

        console2.log("Deployed to address", proxy);

Hi @RishSharma, you would need to deploy on one chain at a time, since connecting to multiple chains simultaneously is not supported by Foundry.

For source code verification, can you try it again by submitting another deployment, since a bug related to verification was recently fixed in Defender.

1 Like

Will it be possible to use hardhat deploy scripts in my foundry repository and then use OZ Defender for a multisig multichain deployment? If yes, please help me with the steps.

I'm not sure what you mean. Hardhat also connects to only one network at a time.

If needed, you could directly use the Defender SDK to perform customized deployments from your own Typescript/Javascript code.

Okay, thanks I got it. One additional blocker that I have been facing with forge deploy.
I tried giving all chmod permissions to the out/ directory but it reverts after first deployment.

Can you try updating your foundry.toml file to give read access to the out directory?

fs_permissions = [{ access = "read", path = "out" }]

Yes, with this change the error is slightly different

I've opened a GitHub issue to address this error:

This could be due to outdated versions of the build info file in out/build-info

To avoid this, can you run forge clean first, or include the --force option when running your forge script command?

1 Like