0

Trying to setup my development environment to start a personal dapp project.

I am starting off the project with the React truffle box.

1) I start by running truffle develop which launches a local dev blockchain on localhost port 9545, I connect metamask to it, then I move some ether from accounts[0] to my metamask address.

2) I then start the react app located in the /client directory of the truffle project with npm start.

First time I did this everything worked perfectly, I would load the page, confirm the transaction to store the number "5" in the contract, and finally see the value "5" appear on the page. So everything good until this point.

Then I CTRL+C everything (the truffle develop terminal tab and the react app terminal tab), restart everything once again by repeating the steps above, and surprisingly the dapp does not work anymore, I get this error when interacting with the contract thru metamask:

the error that appears in metamask

Then metamask closes the window really fast. If I open the console I see this: the errors that appear in the console

So why this inconsistency with the local dev environment? My hypothesis is be that some information about the old local dev blockchain is cached somewhere, so when I re-run everything metamask gets some info from the old chain? No idea...

Thanks for your time guys! Any feedback is super appreciated!

  • Does it happen only when you restart your truffle develop environment? Can you check if truffle reset the develop blockchain every time you restart? Perhaps it is confusing MetaMask. – Ismael Sep 16 at 4:26
  • Yes only when I re-run truffle develop the bug is introduced. No modification at all in the code. Good point, a valid reason can be that Metamask gets confused by this, I just need to understand why and how to avoid this. – bitfede Sep 16 at 4:43
  • Metamask will cache something like nonce or transaction history so that might be the cause of you issues. From Settings/Advanced/Reset Account you can clear any details. If that is the issue then probably you want to run a separate instance of ganache. – Ismael Sep 16 at 20:47
  • Ah yes! I think that was the problem! I did Reset Account and then it worked perfectly! thank you so much :) Yea at least with ganache I can get some persistency – bitfede Sep 20 at 3:08

Your Answer

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

Browse other questions tagged or ask your own question.