How to connect moralis with Ganache. i am trying hard but it does not work
You need to spin up a local dev chain server, then you can follow the instructions under the âView Detailsâ section.
Hereâs a video that may also help:
https://www.youtube.com/watch?v=aRRS394is1U
we can not find those option in updated moralis. There is no more option to connect to ganache
i am trying to connect with ganache but i could not see any option as shown in video.
what can i do?
Hey @ramsir011, hope you are well.
Here you have tutorials for it: https://docs.moralis.io/moralis-server/web3/setting-up-ganache
Hope it helps
Carlos Z
Can you confirm that this server you are sharing is a âLocal Dev Chainâ server? It would normally say Ganache. Because the options you are showing suggests itâs either Testnet or Mainnet server.
Thank you so much. now i got it
in the lesson for 201 , an emulator is used, which one was it ? where do I download it from and how to install emulator?
thanks
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
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:
- 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âŚ
-
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â
-
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.
-
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
Carlos Z
Hey @ramsir011, hope you are well.
Please provide the code in the following way so we can help you review it properly
Carlos Z
Hi! What are the plugins used for?
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?
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
Carlos Z
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