Error: VM Exception while processing transaction:

2019-08-21 02:52发布

I have no idea why I'm getting this error. And honestly I don't quite understand what it even means. This is being tested on ganache, and everything else works fine, until this...

Feel free to ask for any info that may have been left out. Thanks in advance.

Solidity Code

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);
    }

}

Front-end - jQuery/web3js Code

  $('#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条回答
登录 后发表回答