I have a contract which offers two functions:
1) A state modifying function which takes two parameters
2) A constant function
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.
Here's how I'm calling from web3 1.0:
contract.methods.createNewPlayer(
'0x35000f8407c2358Fbb089C2aE4e70fE005f4F6cD',
100
).send({ from: '0xc7edb363e01f7964f9fac9bf883afeee64fb2d93' })
.then((receipt) => {
console.log(receipt)
})
.catch((error) => {
console.log(error);
});
This results in an invalid opcode. And when I call from Truffle console like so:
inst.createPlayer(
'0x35000f8407c2358Fbb089C2aE4e70fE005f4F6cD',
100, { from: '0xc7edb363e01f7964f9fac9bf883afeee64fb2d93'})
Everything works.
What reasons could there be for this? The contract is deployed on TestRPC.