【问题标题】:Smart contract transfer eth to address failed智能合约将 eth 转移到地址失败
【发布时间】:2020-10-25 01:44:24
【问题描述】:

我正在尝试将 eth 从智能合约发送到合约所有者的地址,但没有成功。这是我的合约函数:

function ownerDebit(uint amount) public payable onlyOwner returns(bool status){
  status = owner.send(amount);
  return status;
}

我正在使用 NodeJS 和 Web3JS 与此合约进行交互:

contract.methods.ownerDebit(10000000000000000).call().then(function(response){
    console.log(response);
});

console.log 中的响应是“true”。

但我帐户中的 eth 保持不变。

任何建议都会有所帮助!

【问题讨论】:

    标签: blockchain ethereum solidity smartcontracts web3


    【解决方案1】:

    address(this) 用于获取合约的地址。

       status = address(this).transfer(owner, amount)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-02
      • 2018-10-18
      • 2022-10-22
      • 2022-08-03
      • 2022-08-23
      • 2021-09-17
      • 2023-03-15
      • 1970-01-01
      相关资源
      最近更新 更多