I havenât tested it on an other pc, do you want me to try that?
with exact server url and app id works on your PC?
how do you send the code on the server, is the code identical?
With the exact server url and app id yes, Iâve zipped the code -> uploaded to the server -> unzipped the code
maybe you can try to run a simple js script on the server manually to see how it works, it looks like there is some kind of server running there in js when it doesnât work
Sorry what do you exactly mean with this?
from the initial image, it looks like something more complex than a script with 10 lines of code that runs
So Iâve made like a simple 1 function test code and it returned to owner of the nft inserted (this is the right id) but a bit later it gave the error again, so is it maybe like an error that itâs trying to connect a lot which causes it to error?
it looks like a different type of issue now, maybe you can add more debugging with console.log to see how many times it is called
Well itâs weird because itâs only fired once atm and it prints like something infront of the âMoralis.startâ and it takes like 5-10 seconds but in the mean time it can do the functions.
I donât know exactly, I donât have enough information
try to add some debugging, run a simpler script
I mean itâs just 1 function and itâs still getting the error
const express = require("express");
const Moralis = require('moralis/node');
var Web3 = require('web3');
const app = express();
const { MANAGER } = require("./config/smartcontracts.config");
const { managerABI } = require("./abis/manager");
// Initizalise
async function initMoralis(){
const start = await Moralis.start({ serverUrl: "", appId: "" }).catch((err) => { console.log(err) });
console.log(Moralis.CoreManager.get("VERSION"))
}
initMoralis();
async function getNFTOwner(){
const address = '0x8bac6324c21b3db9d385a9172cea41ff36669f41'
const tokenId = 1
const endPoint = '';
const provider = new Web3.providers.HttpProvider(endPoint);
web3 = new Web3(provider);
contract = new web3.eth.Contract(managerABI, MANAGER)
const owner = await contract.methods.getTokenOwner(address, tokenId).call().catch((err) => { console.log(err) });
console.log(owner)
}
// Repeat get all items every x minutes
setInterval(getNFTOwner, 1000); // 60.000 is 1 minute.
// Start server
app.listen(4000, () => {
console.log("API has been started on port 4000!");
})
try to use await here maybe
where was the endpoint initialized?
in particular this code doesnât need moralis, as it doesnât use any feature from it like web3api
If you would want to do that it should be done in the listen I think
like this:
// Start server
app.listen(4000, async() => {
await initMoralis()
console.log("API has been started on port 4000!");
})
But that still gives the same error
The endpoint is initialised above it, but this is an endpoint from moralis as well
you mean that you hardcoded a speedy node url as that endPoint?
yes, indeed. Is that something that you shouldnât do?
that is fine, it looks like you donât use Moralis SDK in that code, in this case you donât even need to init it
Oh yeah ofcourse, but like for other codes that I need it doesnât work like for example:
const express = require("express");
const Moralis = require('moralis/node');
var Web3 = require('web3');
const app = express();
const { MANAGER } = require("./config/smartcontracts.config");
const { managerABI } = require("./abis/manager");
// Initizalise
async function initMoralis(){
const start = await Moralis.start({ serverUrl: "https://rmatpmaksrdg.usemoralis.com:2053/server", appId: "dPGQ7D2JsTCoKnL98tLnLxWwewVjrJHSWD5AfeVi" }).catch((err) => { console.log(err) });
console.log(Moralis.CoreManager.get("VERSION"))
}
initMoralis()
async function getAllTokenIds(){
const tokens = await Moralis.Web3API.token.getAllTokenIds({ address: "0x8bac6324c21b3db9d385a9172cea41ff36669f41", chain: "rinkeby", }).catch((err) => { /*console.log(err)*/ });
if(tokens){
return tokens
} else {
return null
}
}
// Repeat get all items every x minutes
setInterval(getAllTokenIds, 1000); // 60.000 is 1 minute.
// Start server
app.listen(4000, async() => {
console.log("API has been started on port 4000!");
})