1

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?

4
  • 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. Commented Dec 1, 2019 at 5:38
  • How would I test if this was the case or not? Commented Dec 1, 2019 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. Commented Dec 1, 2019 at 8:18
  • I had the exact same issue, resetting my Metamask account worked. Thank you :) Commented Apr 8, 2020 at 11:12

1 Answer 1

4

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!

1
  • I needed to do this with ganache-cli as well when I resetted the blockchain state by clearing the files where blockchain is stored. Metamask seems to not detect the blockchain state is changed and therefore sends wrong parameters in calls.
    – kuzdogan
    Commented Apr 24, 2020 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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