I am trying to execute the function swapExactTokensForTokens on testnet bsc user interface for the router smart contract of bsc tesnet : 0x9a489505a00cE272eAa5e07Dba6491314CaE3796

when I fill the first input field with 0.01 I dont receive 0.01 tbnb worth of the any other token, I only receive a very small amount, here is an example of a transaction I made : small amounts received but my wallet lost O.01 tbnb

I think the issue is related to some mistake I am making in the input fields :

can some one please tell me what should I write in each input field be cause I am lost at this point, thanks!!

1 Answer 1

  • amountIn: The amount of input tokens to send for swap
  • amountOutMin: The minimum amount of output tokens that must be received; use getAmountsOut(uint amountIn, address[] memory path) to determine this
  • path: Pools for each consecutive pair of addresses must exist and have liquidity
  • to: Address of who you're sending the tokens to

Amounts are in Wei = (amount ETH - or BNB in your case) x (10^18)

  • 1
    thanks a lot! I have two additional question to be able to fully understand : 1) what about the first input field named like the function : "swapExactTokensForTokens"? 2) what if I want to swap "cake" against "XYZ" token (with existing pool) I will just need to add the two tokens adresses in the path and insert the amount of cake x10^18 in amountIn ? Oct 18, 2023 at 1:49
  • Not sure about first field; standard Router code doesn't have that first field for swapExactTokensForTokens
    – Ian Moore
    Oct 18, 2023 at 2:48
  • thanks a lot, I am still not able to understand how to go back from cake to any other token, I did the first transaction (tBNB ==> cake) and now I just want to go back but nothing is working, I flip the adresses in the path flip the value amoutIn and amountOut, nothing is working ... thank's a lot for the help. Oct 18, 2023 at 3:23

Your Answer

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

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