0

Here is the code I've wrote:

Swap Token Gist

Here's one of the TxId with the revert:

BSC Scan Tx Id

And here is a screenshot with the revert message:

Reverted

Why is the contract reverting if there are reserves, I've triple checked before directly on the pair contract?.

https://bscscan.com/address/0x2D9948C34F67435a7b092E45Ea399093e16223A9#writeContract

5
  • You're passing only 250k gas, is it what the wallet is estimating? Seems quite low Dec 27, 2022 at 14:03
  • I hardcoded it but yes, I used an estimated, I've raised the value, still the same error: bscscan.com/tx/… Dec 27, 2022 at 15:12
  • Nope, not the same error anymore: now it's reverting with INSUFFICIENT_INPUT_AMOUNT, as you're calling swapExactETH(...) without passing a msg.value Dec 27, 2022 at 16:20
  • oh man, it was that, thanks now it works!, thank you, how do I close the question as answered?, I'm new around... Dec 28, 2022 at 12:56
  • I added it as an answer that you might now accept;) Dec 28, 2022 at 22:10

1 Answer 1

0

It looks like you're facing 2 issues:

  • the transaction you mention revert without obvious reason, but you might notice the gas left at 0 (and the gas passed as 250k). This is really low (difficult to estimate as it will depend on the token implementation, but see this random swap consuming more than 1 million for instance https://bscscan.com/tx/0xc40e6ba9340e5b0de31034f6e318b408c3b8b5a89ec0c208959d72ab52378bdc)
  • You use swapExactETHForTokensSupportingFeeOnTransferTokens yet do not pass any value (ie use a msg.value reflecting the amount of eth or bnb you'd like to swap)
1
  • Thank you, it's solved now! Dec 29, 2022 at 12:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.