Something is wrong with my smartcontract

I am follwing the tutorials on youtube - i cloned rarible in 24 hours and have some issues with my smartcontract.

‘’’’’

pragma solidity ^0.8.0;

import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";

import "../node_modules/@openzeppelin/contracts/utils/Counters.sol";

contract MorarableToken is ERC721 {

    using Counters for Counters.Counter;

    Counters.Counter private _tokenIds;

    constructor () ERC721("MorarableToken", "MORA"){}

    struct Item {

        uint256 id;

        address creator;

        string uri;

    }

    mapping (uint256 => Item) public Items;

    function createItem(string memory uri) public returns (uint256){

        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();

        _safeMint(msg.sender, newItemId);

        Items[newItemId] = Item(newItemId, msg.sender, uri);

        return newItemId;

    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {

        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

       return Items[tokenId].uri;

    }

}

the error i am getting is

‘’’’’’’’


inpage.js:1 MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction: revert","code":-32000,"data":{"0x5dd8a7967eec87c4f3fecc6e6135c6269db3d61d1de19c0ec753c8ee5b575ccf":{"error":"revert","program_counter":70,"return":"0x"},"stack":"RuntimeError: VM Exception while processing transaction: revert\n    at Function.RuntimeError.fromResults (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\utils\\runtimeerror.js:94:13)\n    at BlockchainDouble.processBlock (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\blockchain_double.js:627:24)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)","name":"RuntimeError"}}}}' {code: -32603, message: "Error: [ethjs-query] while formatting outputs from…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'"}
(anonymous) @ inpage.js:1
(anonymous) @ inpage.js:17
_runReturnHandlers @ inpage.js:17
_processRequest @ inpage.js:17
async function (async)
_processRequest @ inpage.js:17
_handle @ inpage.js:17
handle @ inpage.js:17
_rpcRequest @ inpage.js:1
(anonymous) @ inpage.js:1
request @ inpage.js:1
bound bound request @ util.js:693
c.send @ index.js:156
h @ index.js:615
(anonymous) @ index.js:633
o @ index.js:533
a @ util.js:689
b.run @ browser.js:153
p @ browser.js:123
setTimeout (async)
u @ browser.js:41
o.nextTick @ browser.js:143
(anonymous) @ util.js:694
Promise.then (async)
bound bound request @ util.js:694
c.send @ index.js:156
h @ index.js:615
n @ index.js:642
n @ index.js:624
d._executeMethod @ index.js:841
mintNft @ main.js:135
createItem @ main.js:114
async function (async)
createItem @ main.js:109
main.js:131 Uncaught (in promise) {code: -32603, message: "Error: [ethjs-query] while formatting outputs from…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'", stack: "Error: Error: [ethjs-query] while formatting outpu…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'"

‘’’’’’’’

Can u show ur intitial migration code

// SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.9.0;

contract Migrations {
  address public owner = msg.sender;
  uint public last_completed_migration;

  modifier restricted() {
    require(
      msg.sender == owner,
      "This function is restricted to the contract's owner"
    );
    _;
  }

  function setCompleted(uint completed) public restricted {
    last_completed_migration = completed;
  }
}

const Migrations = artifacts.require("Migrations");

module.exports = function (deployer) {
  deployer.deploy(Migrations);
};


and

const MorarableToken = artifacts.require("MorarableToken");


module.exports = function (deployer) {
  deployer.deploy(MorarableToken);
};

constructor () public ERC721("MorarableToken", "MORA"){}
Try this let me know if it works or not

in which file should i replace this?

this file,

pragma solidity ^0.8.0;

import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";

import "../node_modules/@openzeppelin/contracts/utils/Counters.sol";

contract MorarableToken is ERC721 {

    using Counters for Counters.Counter;

    Counters.Counter private _tokenIds;

    constructor () public ERC721("MorarableToken", "MORA"){}

    struct Item {

        uint256 id;

        address creator;

        string uri;

    }

    mapping (uint256 => Item) public Items;

    function createItem(string memory uri) public returns (uint256){

        _tokenIds.increment();

        uint256 newItemId = _tokenIds.current();

        _safeMint(msg.sender, newItemId);

        Items[newItemId] = Item(newItemId, msg.sender, uri);

        return newItemId;

    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {

        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

       return Items[tokenId].uri;

    }

}

if that doesnt compile you should check this URL https://eips.ethereum.org/EIPS/eip-721#simple-summary

thank you for your reply. So to compile this i would use truffle migrate --reset or should i type anything else to compile it?

This is where i found the code examples, thats why i added public, but here u can find more examples. Hope it helps. Cheers!
https://docs.openzeppelin.com/contracts/3.x/erc721

yes, use truffle migrate --reset to compile again.

still the same error

inpage.js:1 MetaMask - RPC Error: Error: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"message":"VM Exception while processing transaction: revert","code":-32000,"data":{"0xba3e51fb2232b0a745c37e608f2098e23fd86ff4cd75212b3ed3403229a8e925":{"error":"revert","program_counter":70,"return":"0x"},"stack":"RuntimeError: VM Exception while processing transaction: revert\n    at Function.RuntimeError.fromResults (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\utils\\runtimeerror.js:94:13)\n    at BlockchainDouble.processBlock (C:\\Program Files\\WindowsApps\\GanacheUI_2.5.4.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache-core\\lib\\blockchain_double.js:627:24)\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)","name":"RuntimeError"}}}}' {code: -32603, message: "Error: [ethjs-query] while formatting outputs from…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'"}
code: -32603, message: "Error: [ethjs-query] while formatting outputs from…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'", stack: "Error: Error: [ethjs-query] while formatting outpu…/task_queues.js:93:5)\",\"name\":\"RuntimeError\"}}}}'"}

Its super fustrating because i have used days to check my codes line by line and watching the tutorials over and over to see if i have missed something… zooming out and in of the window ect…

thank you for giving it a shot @bouncyknighter

unsure if these images will make the reading easier

After multiple restarts ect it didnt work and i gave up… today i restarted the project again to start coding it from first step and now it works… i dont know why it didnt work before