How to Build Serverless Dapps Part 1 - Web3.js & Moralis Programming Tutorial

Hi, I am following the part 1 tutorial, and I’m running into a smart contract error (I just copy pasted the smart contract). My Ganache Wallet has 97 ETH. Any idea what this is about?

inpage.js:1 MetaMask - RPC Error: [ethjs-query] while formatting outputs from RPC ‘{“value”:{“code”:-32603,“data”:{“message”:“VM Exception while processing transaction: invalid opcode”,“code”:-32000,“data”:{“0x830272091ecfbda07e21c344bed01557a1c0c65d5d4121abab76ebeeacae96de”:{“error”:“invalid opcode”,“program_counter”:461,“return”:“0x”},“stack”:“RuntimeError: VM Exception while processing transaction: invalid opcode\n at Function.RuntimeError.fromResults (/Applications/\n at BlockchainDouble.processBlock (/Applications/\n at runMicrotasks ()\n at processTicksAndRejections (internal/process/task_queues.js:93:5)”,“name”:“RuntimeError”}}}}’ {code: -32603, message: [ethjs-query] while formatting outputs from RPC '{…/task_queues.js:93:5)","name":"RuntimeError"}}}}'}

It looks like something didn’t work well. You should compile the smart contract, deploy it on your local Ganache, get its address, add the smart contract address in your code, and then try to execute that flip function.

Yeah, I did that. Didn’t seem to work. Wondering if I have to start from scratch in a new project.

I’m wondering if the issue is that the FlipContract.sol requires solidity 0.7.5, while the openzeppelin contracts require 0.8.0. I switched 0.7.5 to 0.8.0 in the FlipContract, but maybe that’s causing the issue?

It looks like I used pragma solidity ^0.8.5; when I compiled that smart contract in the past.
For now I don’t think that solidity version was the problem, but you can try to see if it works with another version.

For future reference, I was using the Ganache UI, and there seems to be some issue with it. I used ganache-cli and it worked fine.

Found this helpful: