Bill Contract: payBill(uint toFond)
Closed this issue · 1 comments
Xeratec commented
The payBill() function has a bug and reverts sometimes.
Error somewhere here:
// Check for open bill
require(this.hasBill(msg.sender),"sender needs bill");
uint tokenAmount = _tokenContract.balanceOf(msg.sender);
// Check for sufficant tokens
require(toFond <= tokenAmount,"enough tokens to give to fond");
// Check for sufficant ehter
require(msg.value+toFond <= openBills[msg.sender].amount,"not sufficient ether");
// Reduce bill with tokens
openBills[msg.sender].amount -= tokenAmount-toFond;
_tokenContract.useToken(msg.sender);
// Pay ether to issuer
//openBills[msg.sender].issuer.transfer(openBills[msg.sender].amount);
//openBills[msg.sender].amount -= msg.value;
openBills[msg.sender].amount = 0;
// Pay ether to fond
_fondContract.invest.value(toFond)(msg.sender);
Xeratec commented
Getting this response if slider is pulled to the left
ALERT: [ethjs-rpc] rpc error with payload
{
"id": 9325713267276,
"jsonrpc": "2.0",
"params": [
"0xf893048504a817c800831e8480944e936a15a7d6371caaeff860db19cf9579fd02a6888ac7217a3fd26883a4f0975190000000000000000000000000000000000000000000000000000007850f5a5c18822d45a0a431b44f6aa4150d9b922fe59f2129ee1b83bad43d2375aea2132b3aefcd2aefa054991fb539d363b7c562b6a1b36463b6dae1da3f1df6e451064bb73577c9101b"
],
"method": "eth_sendRawTransaction"
}
Error: VM Exception while processing transaction: revert not sufficient ether