Moralis Course Help Thread

const serverUrl = “https://mg7bo35bvnr0.usemoralis.com:2053/server”;

const appId = “xltfxOMya7zPYfh6d4jzeYBeM1qAhLq2SuW0ObpA”;

Moralis.start({ serverUrl, appId });

const TOKEN_CONTRACT_ADDRESS = “0x9bC9d174270872E6401ede67C0A8A6B0A959722c”;

init = async () => {

hideElement(userInfo);

hideElement(createItemForm);

Window.web3 = await Moralis.enableWeb3();

Window.tokenContract = new web3.eth.Contract(contracttokenAbi, TOKEN_CONTRACT_ADDRESS);

initUser();

};
im getting this error main.js:13 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘Contract’)

This is my contract file;
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.10;

import “@openzeppelin/contracts/token/ERC721/ERC721.sol”;

import “@openzeppelin/contracts/utils/Counters.sol”;

contract nftToken is ERC721 {

using Counters for Counters.Counter;

Counters.Counter private _tokenIds;

constructor () ERC721('nftToken', 'RS'){}

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;

   

}

}
What i am getting wrong

1 Like

Window.tokenContract = web3.eth.Contract(tokenContractAbi, TOKEN_CONTRACT_ADDRESS);
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘Contract’)
I m getting this error

Im having an issue when is comes to updating info on the server. I made an votedCoins object as part of the user object. It is an array of objects that has an ID and Timestamp. I am able to find the right object in the array doing something like this:

const isFound = user.attributes.votedCoins?.find( item => item.id === props.coin.binanceSmartChain )

But now Im not sure how to update just that one objects new timestamp. If i use user.add() or user.addUnique it just pushes another object into the array.

this is how I was trying to add it.

let d = new Date()
            user.fetch().then(user => {
                user.addUnique("votedCoins",
                {
                    id: props.coin.binanceSmartChain,
                    votingTime: d
                });
                user.save();
            });

Having some trouble with the course at step 402, 403. Would appreciate your help:

  1. git clone https://github.com/MoralisWeb3/course-resources.git doesn’t really download the full repo. I get an empty folder instead. git status says everything is deleted:
    D:\Documents\course-resources>git status
    On branch main
    Your branch is up to date with ‘origin/main’.

Changes to be committed:
(use “git restore --staged …” to unstage)
deleted: “201/Icon\r”
deleted: 201/wallet.html
deleted: “202/Icon\r”
deleted: 202/acl-index.html
deleted: “301/Icon\r”
deleted: 301/bootstrap-5.1.3-examples.zip
deleted: “301/bootstrap-5.1.3-examples/Icon\r”
deleted: “301/bootstrap-5.1.3-examples/bootstrap-5.1.3-examples/Icon\r”
deleted: “301/bootstrap-5.1.3-examples/bootstrap-5.1.3-examples/album-rtl/Icon\r”
etc…

  1. One of the folders is named “402 & 403” which breaks VSCode/LiveServer on Windows. The folder can’t have a space. Pls change it to something like “402_403”

  2. The AppID/ServerURL settings are kind of a mess. Sometimes they are placeholders, sometimes they are left over from the author’s settings. And they are set in multiple places. Should be a single file/location. Would help to have an error message in the UI (or console) if you forgot to set them.

  3. Looks like there’s a bug in /402_403/dashboard.html. I get this in the console when I load the page:
    Uncaught (in promise) ReferenceError: listAvailableTokens is not defined
    at main.js:61
    at main.js:67
    (anonymous) @ main.js:61
    (anonymous) @ main.js:67

Thanks,
Alon

Name: Live Preview
Id: ms-vscode.live-server
Description: Hosts a local server in your workspace for you to preview your webpages on.
Version: 0.2.11
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-vscode.live-server

I guess you ask for that one, the live previewer of the website using a webserver, i use that one while programming using Visual Code. Hope it helps :nerd_face:

Carlos Z

Hey @ramsir011, hope you are well.

Please provide the code in the following way so we can help you review it properly :nerd_face:

Carlos Z

Hi! What are the plugins used for?

1 Like

Hi, there are two courses under the “Moralis” tab: Defi 101 and JavaScript for Beginners.
Is there a full Moralis course that I can’t access?

1 Like

Hey @imanidavis.id, hope you are good.

You can read all about it here: https://docs.moralis.io/moralis-server/plugins

Carlos Z

Indeed sir, we do have a fresh new JavaScript course which include the moralis sdk on the project you will made on the course :nerd_face:

Carlos Z

1 Like

Thanks mate. Yes, I see it’s a new course with a new instructor: Zsolt Nagy

Hi Ivan,

I just want to know if there is a prerequisite to starting this course.
I’ve been watching some of these videos but been getting stuck in a lot of areas that involve Visual Studio. Is there a way to learn something else before jumping into this right away? or should I just keep trying new ways to set up VS.

Thank you

1 Like

Hello, there used to be a mobile app to access course material on Ivan on Tech. I can’t find that here. Is there an app to access the courses at Moralis? Thanks

1 Like

The new website is compatible with mobile, should work fine by just open the website on a mobile:
https://academy.moralis.io/

Carlos Z

Hey @Ayman, hope you are well.

Which issue do you have with VS? could you explain it a little bit more on detail?

Carlos Z

202/acl-index.html

Happy New Year’s Eve!

regarding the file above(202/acl-index.html) I was able to add a comment for each user and they appear on my moralis dashboard when I open up the server

acl1

, but I am unable to view the comments on the front end( like chris has as his example in the video).

What can I do to make the comments appear below the comment box for each user?

any feedback is appreciated

cheers in advance

1 Like

Hi I’m new to Moralis and on the second tutorial (Login). I am getting the following errors when trying to login:
From Dashboard Logs:
Error: Signing message has expired.
at /moralis-server/lib/Adapters/Auth/moralisEth.js:48:13
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)

From Chrome Console:
moralis.js:28007 You are not using the latest version of the SDK. Please update it as soon as possible to enjoy the newest features. Most recent version: 0.0.180
(anonymous) @ moralis.js:28007
inpage.js:1 MetaMask: The event ‘close’ is deprecated and may be removed in the future. Please use ‘disconnect’ instead.
For more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect
_warnOfDeprecation @ inpage.js:1
on @ inpage.js:1
u.setProvider @ index.js:131
e @ index.js:39
packageInit @ index.js:45
d @ index.js:39
(anonymous) @ moralis.js:4597
tryCatch @ moralis.js:44057
invoke @ moralis.js:44288
(anonymous) @ moralis.js:44113
asyncGeneratorStep @ moralis.js:28197
_next @ moralis.js:28219
(anonymous) @ moralis.js:28226
Wrapper @ moralis.js:35622
(anonymous) @ moralis.js:28215
_getWeb3FromBrowser @ moralis.js:4624
getWeb3FromBrowser @ moralis.js:4569
(anonymous) @ moralis.js:4646
tryCatch @ moralis.js:44057
invoke @ moralis.js:44288
(anonymous) @ moralis.js:44113
asyncGeneratorStep @ moralis.js:28197
_next @ moralis.js:28219
(anonymous) @ moralis.js:28226
Wrapper @ moralis.js:35622
(anonymous) @ moralis.js:28215
(anonymous) @ moralis.js:4662
(anonymous) @ moralis.js:5540
tryCatch @ moralis.js:44057
invoke @ moralis.js:44288
(anonymous) @ moralis.js:44113
asyncGeneratorStep @ moralis.js:28197
_next @ moralis.js:28219
(anonymous) @ moralis.js:28226
Wrapper @ moralis.js:35622
(anonymous) @ moralis.js:28215
(anonymous) @ moralis.js:5558
(anonymous) @ moralis.js:5723
tryCatch @ moralis.js:44057
invoke @ moralis.js:44288
(anonymous) @ moralis.js:44113
asyncGeneratorStep @ moralis.js:28197
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
(anonymous) @ moralis.js:28226
Wrapper @ moralis.js:35622
(anonymous) @ moralis.js:28215
(anonymous) @ moralis.js:5807
login @ index.html:23
Show 13 more frames
moralis.js:25496 POST https://44aus0vdim3u.usemoralis.com:2053/server/users 404
dispatch @ moralis.js:25496
ajax @ moralis.js:25503
(anonymous) @ moralis.js:25610
Promise.then (async)
request @ moralis.js:25604
task @ moralis.js:17745
value @ moralis.js:26228
enqueueTask @ moralis.js:25944
save @ moralis.js:17758
(anonymous) @ moralis.js:16121
Promise.then (async)
value @ moralis.js:16120
value @ moralis.js:23986
linkWith @ moralis.js:25055
value @ moralis.js:23518
value @ moralis.js:24393
(anonymous) @ moralis.js:5771
tryCatch @ moralis.js:44057
invoke @ moralis.js:44288
(anonymous) @ moralis.js:44113
asyncGeneratorStep @ moralis.js:28197
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
Promise.then (async)
asyncGeneratorStep @ moralis.js:28207
_next @ moralis.js:28219
(anonymous) @ moralis.js:28226
Wrapper @ moralis.js:35622
(anonymous) @ moralis.js:28215
(anonymous) @ moralis.js:5807
login @ index.html:23
moralis.js:28265 Uncaught (in promise) Error: Signing message has expired.
at handleError (moralis.js:25632)

Please assist

1 Like

Hey @Lucky_Seuoe, hope you are well.

You probably just need to login with metamask again, apparently the signing message has expired, so just try to sign the login message again :nerd_face:

Carlos Z

Hey @Charles7, hope you are well.

The code is working fine, i was able to also post a comment and check it on my server dashboard properly.

Now I think that what is missing is the getData cloud function which should be explained by Chris on the same lesson, sadly im not able to watch the video right now, but i can suggest you to keep watching it a little bit further and he should explain you the cloud function that must be created in your server to get the comments data.

Carlos Z

Thanks I was able to use the getData cloud function successfully

Happy New Year!

1 Like