I have a web frontend in React calling these functions. When I call the constant function from the React frontend, everything works. But when I call the state modifying function from the frontend using web3, I get an invalid opcode error. However, the function does work when I call it from Truffle console, so the Solidity function itself is correct.