I want to swap a token to BNB
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
I do not know what to put on calldata path
, I've tried this
path
{
tokenContractAddres,
wBNBAdress
}
And when I do a manual swap on pancakeSwap and check the input data , it basically does this, I've search around , it looks like I have to approve it first, when I look at the transaction hash it shows that approve takes an address (the pancake router) and a uint256
So my questions are:
- In the approve function what goes in the uint256 argument?
- After the approve function, how do I get the calldata path for the
swapExactTokensForETHSupportingFeeOnTransferTokens
function?
The
approve() function
about ERC20 token allow you to set the address of spendere (typeof: address) and amount that this address can spend (typeof:uint256). Having said that, in the approve function you must to insert:For path to swap the tokens with BNB, you can use this:
UniswapV2Router02.WETH()
: this function permit you to have directly the address of native coin (in this case BNB).