我正在为我写的一份牢固的合同写一份硬质测试。契约包含一个receive() external payable { ... }函数。我怎么能用以太量的安全帽测试来称呼它呢?
发布于 2021-06-27 11:08:54
您可以进行事务处理,并将以太发送到合同地址。
const [owner] = await ethers.getSigners();
const transactionHash = await owner.sendTransaction({
to: "contract address",
value: ethers.utils.parseEther("1.0"), // Sends exactly 1.0 ether
});进行事务处理时,应该调用接收函数。
发布于 2022-11-15 09:22:45
你可以试试这个
await contract.connect(account).receive({ value: ethers.utils.parseEther("1") })https://ethereum.stackexchange.com/questions/102548
复制相似问题