错误:处理事务时VM异常:无效的操作码

时间:2018-10-10 13:21:56

标签: javascript solidity web3

我不知道为什么会出现此错误。老实说,我什至不明白这意味着什么。这已经在ganache上进行了测试,其他一切都可以正常工作,直到...

随时询问可能遗漏的任何信息。预先感谢。

实体代码

function withdraw(uint amount) public {
    assert(amount > 0);
    require(amount <= balances[msg.sender]);

    if(!msg.sender.send(amount)){
        balances[msg.sender] += (amount);
    }else{
        balances[msg.sender] -= amount;
        //emit withdrawalDone("A withdrawal was done", msg.sender, amount);
    }

}

前端-jQuery / web3js代码

  $('#withdraw').click(function(e){
    var value = $('#withdrawalAmount').val()
    bank.withdraw(web3.fromWei(value, 'ether'), function(error,result) {
      if(!error){
        console.log(result);
      }
      else{
        console.log(error);
      }
    })
  });

0 个答案:

没有答案