Moralis sdk error C0005

const express = require(“express”);

const Moralis = require(“moralis”).default;

const app = express();

const cors = require(“cors”);

require(“dotenv”).config();

const port = 3001;

app.use(cors());

app.use(express.json());

app.get("/tokenPrice", async (req, res) =>{

const {query} = req;

const responseOne = await Moralis.EvmApi.token.getTokenPrice({

address: query.addressOne

})

const responseTwo = await Moralis.EvmApi.token.getTokenPrice({

address: query.addressTwo

})

console.log(responseOne.raw);

console.log(responseTwo.raw);

return res.status(200).json({});

});

Moralis.start({

apiKey: process.env.MORALIS_KEY,

}).then(() => {

app.listen(port, () => {

console.log(`Listening for API Calls`);

});

});

this is my code I am getting

MoralisError [Moralis SDK Core Error]: [C0005] Invalid address provided
at EvmAddress.parse this error

1 Like

Hey @Simran,

Did you try to console query.addressOne and query.addressTwo and see what you have? The error indicates that the address input that you provide is not valid.

I got the result now
const express = require(“express”);

const Moralis = require(“moralis”).default;

const app = express();

const cors = require(“cors”);

require(“dotenv”).config();

const port = 3001;

app.use(cors());

app.use(express.json());

app.get("/tokenPrice", async (req, res) =>{

const {query} = req;

const responseOne = await Moralis.EvmApi.token.getTokenPrice({

address: query.addressOne

})

const responseTwo = await Moralis.EvmApi.token.getTokenPrice({

address: query.addressTwo

})

const usdPrices = {

tokenOne: responseOne.raw.usdPrice,

tokenTwo: responseTwo.raw.usdPrice,

ratio: responseOne.raw.usdPrice/responseTwo.raw.usdPrice

}

return res.status(200).json(usdPrices);

});

Moralis.start({

apiKey: process.env.MORALIS_KEY,

}).then(() => {

app.listen(port, () => {

console.log(`Listening for API Calls`);

});

});

for this code how I do not know still I got it

Hey @Simran,

What’s your issue here? By getting the result did you mean now the C0005 error is resolved?

1 Like

I did console log query.addressOne and console log query.addressTwo as you mentioned then run the backend on 3001 port I got nothing then I again replaced it with my original code and it worked

Yes I meant the C0005 error was not showing as it is an sdk error it was resolved .

Great to hear that :grinning_face_with_smiling_eyes:

If you have any other questions, please feel free to open a new post, I’m going to close this one

Have a nice day~