0

Consider I have two contracts A & B. B inherits A.

Now i want to deploy using hardhat and at the same address.

How can i do?

Example of what i want to do, but since in the new hardhat version there is no function as getContractfactory

const { ethers } = require("hardhat");

async function main() {
    const [deployer] = await ethers.getSigners();
    console.log('Deploying contracts with the account: ' + deployer.address);

    // Deploy First
    const First = await ethers.getContractFactory('FirstContract');
    const first = await First.deploy();

    // Deploy Second
    const Second = await ethers.getContractFactory('SecondContract');
    const second = await Second.deploy(first.address);

    console.log( "First: " + first.address );
    console.log( "Second: " + second.address ); 
}

main()
    .then(() => process.exit())
    .catch(error => {
        console.error(error);
        process.exit(1);
})

Instead there is direct

  const contractEvents = await hre.ethers.deployContract("ContractEvents");

  await contractEvents.waitForDeployment();
  console.log(`Contract deployed at ${contractEvents.target}`);

Which is working properly to deploy a single contract, but i want to deploy another contract at the same deployed address i.e the contractEvents.target, any suggestions how can i do? I have read through other articles but they are quiet old and many of the functions couldnt be found like deployContractFactory (error shown by using the first code)

Thank You

1 Answer 1

1

I found the answer, i just need to only one contract i.e deploy the most derived child contract, in its ABI all of the classes functions would be available to use.

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.