Metamask is not pop up for the Approve and Swap

I am using moralis sdk for the approve and swap the tokens. although API is giving correct response but metamask is not poping up.

Approve Request:


Do you see any error in browser console when MetaMask should appear?

No error in console.
This is the subdomain URl:

MetaMask should popup before you connect to server url.
You can also add a simple code for which you would expect metamask to pop up and it doesn’t.

Hi Crtptokid,

I have solved approve token issue. but Now I am facing issue with swap. although I have enough BNB balance for the swap but still I am getting error.




{“result”:{“status”:200,“data”:{“success”:true,“result”:{“statusCode”:500,“message”:“Not enough 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c balance. Amount: 100000000000000. Balance: 0”,“error”:“Internal Server Error”}}}}

I’m not sure if it works with BNB, that token address is for WBNB, but you may also have WBNB if you mentioned about that approve part. It looks like 0x43a0C5EB1763A211Aa3c05849A617f2eE0452767 smart contract has 9 decimals, maybe you didn’t compute that amount right.

I am trying with correct amount i.e 100000000000000 because decimals for WBNB is 18 and I am trying with the amount 0.0001
In simple calculation.
100000000000000/ 10**18 = 0.0001

Take a look at

In the amount field we need to pass the value of amount we want to swap not the value of the token we want to receive. correct?

as per the link I am doing in the right way. as I am trying 0.0001 and 18 decimals and that is equal to 100000000000000
so, what is wrong in the request?

Absolutely right, the problem is that you are trying to swap tokens you don’t have.

Your wallet has only PDX tokens

WBNB - is an ERC20 token wrapped BNB, it has own smart contract and address 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c

BNB is a native crypto without contract address(for 1inch you can use 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE )

1 Like

In my wallet I have both the BNB and PDX.

I have tried with given contract address.



{“result”:{“status”:200,“data”:{“success”:true,“result”:{“statusCode”:500,“message”:“cannot estimate”,“error”:“Internal Server Error”}}}}

did you try to change from PDX to BNB?

Yes Tried both the option and getting

{“result”:{“status”:200,“data”:{“success”:true,“result”:{“statusCode”:500,“message”:“cannot estimate”,“error”:“Internal Server Error”}}}}

Hey @bullish

Works fine for me:

const quote = await Moralis.Plugins.oneInch.quote({
          chain: "bsc", // The blockchain you want to use (eth/bsc/polygon)
          fromTokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // The token you want to swap
          toTokenAddress: "0x43a0c5eb1763a211aa3c05849a617f2ee0452767", // The token you want to receive
          amount: 100000000000000

I just want to say that sometimes it will return you deifferrent error messages like “Internal error” because of a small amount to swap.

For example:
amount: 10000 - { “statusCode”: 500, “message”: “Internal server error” }
amount: 100000000000000 - works fine

Also you can check returns from 1inch swagger

Issue is with swap not with quote endpoint.