我正在试图找出是否有可能设置特定的帐户,从其中部署合同在“白帽”。
在默认情况下,“硬帽子”支持此功能吗?或者我需要包含一些其他的包。
发布于 2022-08-06 16:38:17
你能试试这个吗?
[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);请注意".connect(acc1)“部分,它在部署之前将您连接到帐户1。这会将默认值更改为您想要的任何帐户(在这里,"getSigners()“返回列表中的第二个帐户)。
https://ethereum.stackexchange.com/questions/133131
复制相似问题