MoralisWeb3 / plugindocs

14 stars 14 forks source link

Issue with useOneInchSwap from react-moralis #14

Open ashish-pcode opened 2 years ago

ashish-pcode commented 2 years ago

Using useOneInchSwap from react-moralis

Params: { "chain": "bsc", "fromTokenAddress": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "toTokenAddress": "0x55d398326f99059ff775485246999027b3197955", "amount": "0.1", "fromAddress": "0xc3cd0171dfdd36cb1d77efc07578b69252d65206", "slippage": 1 }

Getting the error

{ "statusCode": 400, "error": "Bad Request", "description": "amount should be a number string", "meta": [ { "type": "paramNumber", "value": "amount" } ], "requestId": "be597da9-171e-4001-a38c-74285704d32f" }

Please help me out.

Thaddeus19 commented 2 years ago

The error is due to the fact that the amount must be converted to wei and then to string. Moralis.Units.Token("the amount or variable that brings the amount", " the decimals of the token, the default is 18").toString()