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.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityCan 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).