I'm trying to call the leafPicked()
function in my contract from web3 which launches Metamask as intended. After pressing accept the transaction shows as failed along with the error message pictured below.
What am I doing wrong?
Contract Function:
function leafPicked(uint numPicked) public returns (uint, uint){
require(numPicked < remaining_leaves);
uint number_before_picking = remaining_leaves;
remaining_leaves -= numPicked;
leafWasPicked(remaining_leaves, numPicked);
return (remaining_leaves, number_before_picking);
}
Web3 function:
web3.eth.getAccounts(function(error, accounts) {
if (error) {
console.log(error);
}
var account = accounts[0];
console.log(account);
App.contracts.Plant.deployed().then(function(instance) {
plantInstance = instance;
// This function is not executing as intended
return plantInstance.leafPicked(parseInt(leafNum), {from: account});
}).then(function(result) {
console("Result from leaf picking: ", result);
return App.SetContractValues();
}).catch(function(err) {
console.log(err.message);
});
});
web3.eth.getTransactionCount(account);
does give 4 which is inline with the error. The tx however is set to 15 - how do I get them to match?