I am trying to find out is it possible to set specific account from which to deploy contract in hardhat.

Does hardhat supports this by default or I need to include some other package.

1 Answer 1


Can you try this?

[theDefaultDeployer, acc1] = await ethers.getSigners();

// we will not use the "theDetaultDeployer" in what follows:
const MyContract = await ethers.getContractFactory("MyContract");
myContract = await MyContract.connect(acc1).deploy(1000);

// let's test it:
expect(await myContract.owner()).to.not.equal(theDefaultDeployer);
expect(await myContract.owner()).to.equal(acc1.address);

Notice the ".connect(acc1)" part that connects you to account 1 before deploying. This changes the default to any account you want (here, the second account in the "getSigners()" returned list).

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.