patractlabs / redspot

Redspot is an Substrate pallet-contracts (ink!) development environment. Compile your contracts and run them on a different networks. Redspot's core forks from Hardhat but changed a lot to suit substrate.
https://redspot.patract.io/
Other
67 stars 22 forks source link

Deployed creates a new contract every time #152

Closed forgetso closed 2 years ago

forgetso commented 2 years ago

Redspot Version 0.13.1-0 In the example deploy scripts you have the following comment:

    // The `deploy` method will attempt to deploy a new contract.
    // The `deployed` method will first find out if the same contract **already exists** based on the parameters.
    // If the contract exists, it will be returned, otherwise a new contract will be created.
    // const contract = await contractFactory.deploy("default", deployer.address);

I used the deployed method to try to deploy or get my contract if it is already deployed:

    const deployerAddress = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; \\Alice
    const contractFactory = await getContractFactory("mycontract", deployerAddress);
    const contract = await contractFactory.deployed("default", deployerAddress, {
        gasLimit: "400000000000",
        value: "10000 UNIT",
    });

Each time I run this script I get a different deployed address for the contract. I would expect to get the same address after the contract was deployed once.

forgetso commented 2 years ago

I see this is because I need to specify a salt when deploying the contract.

    const contract = await contractFactory.deployed("default", deployerAddress, {
        gasLimit: "400000000000",
        value: "10000 UNIT",
        salt: '0x1234'
    });