I'm trying to do a swap on Pancakswap using JS and web3. I am using the swapExactTokensForTokensSupportingFeeOnTransferTokens function on the routerV2 contract. The code in question:
let result = await routerV2Contract.methods.swapExactTokensForTokensSupportingFeeOnTransferTokens(
amountIn, //
amountOutMin, //
[BNB_ADDRESS, BUSD_ADDRESS],
myADDRESS,
DEADLINE); // timestamp in seconds one minute from now
BNB_ADDRESS = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c'
BUSD_ADDRESS = '0xe9e7cea3dedca5984780bafc599bd69add087d56'
amountIn = 5000000000000000 0.005 BNB
amountOutMin = Calculated based on BNB value at the moment
It does return an object in "result" which contains, among other things, A call, send and method component, however the swap doesn't actually happen, nor is an error of any kind given.
I wonder if I should pass gas information in the "send" component, but I can't find information on what the send function requires.
On another note, actually I realized I connected to web3 with just a provider, but it isn't actually an hdwalletprovider. I guess I can't expect it to work, but I would have expected some kind of error, and I will likely still need to know how to send the gas info and provide any other support the function requires.
Can anyone provide clues as to what more I may need?
Or any code samples that would do a web3 swap on the pancakeswap v2 router..?