Cloning Rarible Tutorial - 'Contract' not defined

Been struggling with creating my NFT during the Rarible clone tutorial. I keep getting these 2 errors when trying to create the NFT.

inpage.js:1 MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3
get @ inpage.js:1
mintNFT @ main.js:176
createItem @ main.js:156
async function (async)
createItem @ main.js:139

main.js:176 Uncaught (in promise) TypeError: Cannot read property โ€˜Contractโ€™ of undefined
at mintNFT (main.js:176)
at HTMLButtonElement.createItem (main.js:156)
mintNFT @ main.js:176
createItem @ main.js:156
async function (async)
createItem @ main.js:139

Really not sure what Iโ€™m missing, and have been trying to find solutions for a while now. Thank you for your time.

Hi,
I usually use a code like this to access a contract, you may also have to connect MetaMask to the network where you contract was deployed and be logged in with MetaMask:

    window.web3 = await Moralis.Web3.enable();
    let address = '0x154A9F9cbd3449AD22FDaE23044319D6eF2a1Fab';
    let contractAbi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}];
    let contract = new web3.eth.Contract(contractAbi, address);
    let name = await contract.methods.name().call();
    console.log(name);

Thank you for the quick response. Would this code go at the top of my main.js file?

This code is an example and youโ€™ll have to put your contract address and you contract ABI. You can use this code before the code that calls a contract function.