I have a problem with the following contract. When I deploy it, normally on calling the function addBalance() it should go into the false. But instead, it completely does not work and I get the following message. What's wrong?
VM error: invalid opcode. invalid opcode The execution might have thrown. Debug the transaction to get more information.
How can I find out if a key does not exist?
Contract:
pragma solidity ^0.4.24;
contract MembersContract {
struct Member {
uint balance;
address member;
bool exists;
}
Member[] public members;
constructor() public {
members.push(Member(0, 0x0, true));
}
function addbalance(uint _balance) public returns(bool _success){
if(members[1].exists == true) {
members[1].balance = 400;
}
else {
return false;
}
}
}