Moralis price check via new SDK [SOLVED]

I’m getting strange error while retrieving PAID price via :

                        var options = {
                            address: address_from_info
                        var price = await Moralis.Web3API.token.getTokenPrice(options);

Error: [object Object]
at handleError (RESTController.js:437)
at async makeArrV2 (query.js:473)

all other tokens get correct price, with the same method, is it connected with token address change? Of course I use new SDK to get token address using

await Moralis.Web3API.account.getTokenBalances();

this is response im getting:

  1. balance: “44500000000000000000”
  2. decimals: “18”
  3. logo: “”
  4. name: “PAID Network”
  5. symbol: “PAID”
  6. thumbnail: “”
  7. token_address: “0x1614f18fc94f47967a3fbe5ffcd46d4e7da3d787”

and from your SDK it gets correct token address, any ideas?

Can it be connected with no liquidity on Uniswap v3?

Paid is on uniswap v2 - can you set that in options?

Of course, but then i need to switch to v2 in case of error. Can it be done on SDK side? If for example SDK ask gives this error it auto search liquidity on other versions of Uni? I also added failsafe to use Coingecko API

so did you mean:

                        try {
                            var price = await Moralis.Web3API.token.getTokenPrice(options);
                            price = parseFloat(price.usdPrice).toFixed(2);
                        } catch (error) {
                            var options = {
                                address: address_from_info,
                                exchange_name: "UniSwap v2"
                            var price = await Moralis.Web3API.token.getTokenPrice(options);
                            price = parseFloat(price.usdPrice).toFixed(2);

                            // price = await getPrice(address_from_info, "usd");
                            // price = parseFloat(price).toFixed(2);

seems not working because of wrong factory name in this case “UniSwap v2” i tried factory address:

but doesnt work too, couldnt find also the list of supported exchange names for SDK

where to find factory names supported by SDK?

Hey @legenuspl

Exchanges supported on the ETH chain:

Uniswap v2: 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Uniswap v3: 0x1f98431c8ad98523631ae4a59f267346ea31f984
SushiSwap: 0xc0aee478e3658e2610c5f7a4a2e1777ce9e4f2ac

Names: Uniswapv2, Uniswapv3, SushiSwapv2

I also get an error for
price = await Moralis.Web3API.token.getTokenPrice({address: "0x1614f18fc94f47967a3fbe5ffcd46d4e7da3d787", exchange_name: "Uniswapv2", chain: "eth"});
I also find it strange how that contract is deployed (0x1614f18fc94f47967a3fbe5ffcd46d4e7da3d787), it is a proxy with not too much info.

I tried Uniswapv2 and it’s address 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f like:
var options = {
address: address_from_info,
exchange_name: “0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f”
var price = await Moralis.Web3API.token.getTokenPrice(options);
price = parseFloat(price.usdPrice).toFixed(2);

but same error:
RESTController.js:309 POST 400
dispatch1 @ RESTController.js:309
ajax @ RESTController.js:313
(anonymous) @ RESTController.js:414
Promise.then (async)
request @ RESTController.js:409
run @ Cloud.js:174
run @ Cloud.js:100
wrappers.. @ MoralisWeb3Api.js:172
makeArrV2 @ query.js:493
async function (async)
makeArrV2 @ query.js:455
loadTokensFromChain @ query.js:535
async function (async)
loadTokensFromChain @ query.js:432
loadTokensFromChainM @ main.js:1077
(anonymous) @ VM9000:1
query.js:510 Error: [object Object]
at handleError (RESTController.js:437)
at async makeArrV2 (query.js:493)

same method some tokens get pricing, some not, as Ivan pointed out it is due to no liquidity on V3 that is why i try V2

We found this working example:
price = await Moralis.Web3API.token.getTokenPrice({address: "0x1614f18fc94f47967a3fbe5ffcd46d4e7da3d787", exchange: "Uniswapv2", chain: "eth"});

I’ll check soon, Moralis server response seems to be lagging a lot or something is wrong on my side, i had 1min response on some requests while on other 15ms

CORS is again blocking my requests on every request via SDK

This error with 1 minute response is from Moralis, and will be fixed, is nothing wrong on your side.


Thanks! Very much appreciated :slight_smile:

Possibly team working on this?


  1. Promise {}


  1. {message: ‘Temporarily disabled’}

  2. message: “Temporarily disabled”

Yes, Moralis is working on fixing this.

We Should be back! write if issues are still here

everything works, may be closed as Solved, thx!

1 Like