1

This is my route:

router.post('/withdraw', async (req, res, next) => {
  const {code, address, amount, otpToken, currency } = req.body;

  const exchange = await new ccxt.bitmex();
  exchange.apiKey = "MY - KEY";
  exchange.secret = "MY - SECRET";

  await exchange.withdraw (code, amount, address, tag = undefined, params = {}, otpToken)
  .then((response) => console.log(res))
  .catch(ex => console.log(ex))

});

And this is what i am trying to post:

{
"address": "THE ADRESS",
"amount": 0.0022,
"code": "BTC",
"otpToken": "MY TOKEN"
}

When i execute this route, i get this error:

BadRequest: bitmex {"error":{"message":"amount is invalid","name":"HTTPError"}}

The key and the secret are OK. The otpToken too. I can fetch everything. I´m new on this, and i can´t figure it out where is the error on my code.

Thank you!!

Nicolas Urman
  • 153
  • 1
  • 1
  • 9

2 Answers2

1

The ccxt Team answer my question. This is the answer that works for me:

I think BitMEX requires the amount in satoshis (an integer, not a floating point decimal). So, instead of "amount": 0.0022 it should be "amount": 220000.

Nicolas Urman
  • 153
  • 1
  • 1
  • 9
1

BitMEX requires the withdrawal amount in satoshi (an integer value 220000 instead of a float value 0.0022).

This question was answered in the following issue on GitHub:

Igor Kroitor
  • 1,548
  • 13
  • 16