wighawag / hardhat-deploy

hardhat deployment plugin
MIT License
1.17k stars 283 forks source link

Deterministic deployment with existing factory #415

Open michaelr524 opened 1 year ago

michaelr524 commented 1 year ago

We have a hardhat project with our own deterministic factory, that is already deployed. Is there any way we could use hardhat-deploy with our own deterministic factory? I couldn't find any examples of where with hardhat-deploy to generate the custom call to deploy the contract via the our custom factory. Any pointers to docs or examples would be greatly appreciated!

This is how our factory looks like:

// SPDX-License-Identifier: AGPL-3.0

pragma solidity ^0.8.17;

import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/Create2.sol';
import '@openzeppelin/contracts/utils/Address.sol';

contract DeterministicDeployFactory is Ownable {
        using Address for address;

        event Deploy(address addr);

        function deploy(bytes memory bytecode, bytes32 salt, bytes memory initCall) external onlyOwner {
                address addr = Create2.deploy(0, salt, bytecode);
                addr.functionCall(initCall);
                emit Deploy(addr);
        }
}
wighawag commented 1 year ago

Did you look at https://github.com/wighawag/hardhat-deploy#4-deterministicdeployment-ability-to-specify-a-deployment-factory ?