【问题标题】:How can I test sending Ether to a contract with a `payable` function?如何测试将以太币发送到具有“应付”功能的合约?
【发布时间】:2021-09-09 19:39:07
【问题描述】:

我正在为我编写的 Solidity 合约编写安全帽测试。合约包含一个receive() external payable { ... } 函数。我怎样才能从以太币数量的测试中调用它?

【问题讨论】:

    标签: hardhat


    【解决方案1】:
    const params = [{
            from: sender,
            to: contractAddress,
            value: ethers.utils.parseEther("1") // 1 ether
    }];
    
    const transactionHash = await provider.send('eth_sendTransaction', params)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-22
      • 1970-01-01
      • 2022-11-02
      • 1970-01-01
      • 1970-01-01
      • 2021-04-26
      相关资源
      最近更新 更多