0

I have a truffle project, if I migrate it onto ganache-cli and then interact with my contract (via Metamask) it works great. But if I try and do the exact same thing using ganahe-gui the contract deploys fine, but interacting with it fails.

This is the error:

Error: [ethjs-rpc] rpc error with payload {"id":406503133755,"jsonrpc":"2.0","params":["0xf8ab06843b9aca008303cb1794071faee0d32e420c88295802a65758a924b5626201b844d6febde800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000822d45a087a8df0b863c944ad2f79551800f21289efac79e74d62a8b0c3d7d5580ec4df5a01d92fd24ee5a418df0184bc61db21dd36719ce2a234d11638e092a9c4eb08bca"],"method":"eth_sendRawTransaction"} [object Object

This is not anything to do with my contract code or it would not work with the cli. I think the problem may be metamask? I am using the same 'chain' on Metmask for both gui and cli- localhost:8545. Metamask is detecting the chain properly because I can see that I have 100 ether (99.9 after contract deployment).

Metmask does not give any errors prior to submitting the tx, it is only when I press Send that it gives me the error. If it wasn't detecting the chain, I wouldn't be able to send as I'd have a 0 balance.

Wat do?

  • A wild guess: ganache-cli has your account unlocked on the node, so you can send a raw transaction without signing it with your private key (ganache-cli signs it for you), while Ganache does not have your account unlocked on the node, so you must sign the transaction yourself before sending it. – goodvibration Dec 1 '19 at 5:38
  • How would I test if this was the case or not? – Andrew Stanger Dec 1 '19 at 8:01
  • I don't know ganache, but ganache-cli starts by printing all unlocked accounts on your terminal. Maybe you can find where ganache does the same. – goodvibration Dec 1 '19 at 8:18
1

The answer is: I need to reset metamask between sessions:

Settings > advanced > Reset Account

Not sure why this is needed for ganache gui but not ganache cli!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.