gnosis/safe/safe_service.py
def deploy_proxy_contract_with_nonce(self, salt_nonce: int, initializer: bytes, gas: int, gas_price: int,
                                         deployer_private_key=None) -> Tuple[bytes, Dict[str, any], str]:
        """
        Deploy proxy contract using `create2` withthe `Proxy Factory Contract`.
        Takes `deployer_account` (if unlocked in the node) or the `deployer_private_key`
        :param salt_nonce: Uint256 for `create2` salt
        :param initializer: Data for safe creation
        :param gas: Gas
        :param gas_price: Gas Price
        :param deployer_private_key: Private key of an ethereum account
        :return: Tuple(tx-hash, tx, deployed contract address)
        """
        assert deployer_private_key

        proxy_factory_contract = get_proxy_factory_contract(self.w3, self.proxy_factory_address)
        create_proxy_fn = proxy_factory_contract.functions.createProxyWithNonce(self.master_copy_address, initializer,
                                                                                salt_nonce)
        contract_address = create_proxy_fn.call()

        deployer_account = Account.privateKeyToAccount(deployer_private_key)
        nonce = self.ethereum_client.get_nonce_for_account(deployer_account.address, 'pending')
        # Auto estimation of gas does not work. We use a little more gas just in case
        tx = create_proxy_fn.buildTransaction({'from': deployer_account.address, 'gasPrice': gas_price,
                                               'nonce': nonce, 'gas': gas + 50000})
        signed_tx = deployer_account.signTransaction(tx)
        tx_hash = self.ethereum_client.send_raw_transaction(signed_tx.rawTransaction)
        return tx_hash, tx, contract_address
def deploy_proxy_contract_with_nonce(self, salt_nonce: int, initializer: bytes, gas: int, gas_price: int,
                                         deployer_private_key=None) -> Tuple[bytes, Dict[str, any], str]:
        """
        Deploy proxy contract using `create2` withthe `Proxy Factory Contract`.
        Takes `deployer_account` (if unlocked in the node) or the `deployer_private_key`
        :param salt_nonce: Uint256 for `create2` salt
        :param initializer: Data for safe creation
        :param gas: Gas
        :param gas_price: Gas Price
        :param deployer_private_key: Private key of an ethereum account
        :return: Tuple(tx-hash, tx, deployed contract address)
        """
        assert deployer_private_key

        proxy_factory_contract = get_proxy_factory_contract(self.w3, self.proxy_factory_address)
        create_proxy_fn = proxy_factory_contract.functions.createProxyWithNonce(self.master_copy_address, initializer,
                                                                                salt_nonce)
        contract_address = create_proxy_fn.call()

        deployer_account = Account.privateKeyToAccount(deployer_private_key)
        nonce = self.ethereum_client.get_nonce_for_account(deployer_account.address, 'pending')
        # Auto estimation of gas does not work. We use a little more gas just in case
        tx = create_proxy_fn.buildTransaction({'from': deployer_account.address, 'gasPrice': gas_price,
                                               'nonce': nonce, 'gas': gas + 50000})
        signed_tx = deployer_account.signTransaction(tx)
        tx_hash = self.ethereum_client.send_raw_transaction(signed_tx.rawTransaction)
        return tx_hash, tx, contract_address
Deploy proxy contract using `create2` withthe `Proxy Factory Contract`.
        Takes `deployer_account` (if unlocked in the node) or the `deployer_private_key`
        :param salt_nonce: Uint256 for `create2` salt
        :param initializer: Data for safe creation
        :param gas: Gas
        :param gas_price: Gas Price
        :param deployer_private_key: Private key of an ethereum account
        :return: Tuple(tx-hash, tx, deployed contract address)