Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'Contract') at flip

When I use the code I got this error “Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘Contract’) at flip” .
How can I solve it ? I new to coding. Can you please explain the answer for a newbie :slight_smile:

async function flip(side){
let sideNumber;
if(side == “heads”)
sideNumber = 0;
sideNumber = 1;

let amount = document.getElementById("amount").value;

window.web3 = await Moralis.enableWeb3();
let contractInstance = new web3.eth.Contract(window.abi, "0xCDC5Dd9176A9D23eAE6d199E0ddDd77C4602B30B")
contractInstance.methods.flip(sideNumber).send({value: amount, from: ethereum.selectedAddress})
.on('receipt', function(receipt){

it may be because when that tutorial was made moralis SDK was using web3 by default and now it is using ethers

you could try to use Moralis SDK version 0.0.184

how can I use Moralis SKD version 0.0.184 ?

you add something like this in your html header instead of what you have now for Moralis SDK

<script src="https://unpkg.com/[email protected]/dist/moralis.js"></script>

Yes… Thank you mate. It is working now…
Is it hard to update the code for ethers?

you can read here about that migration to ethers for Moralis SDK: