I am trying to sell my tokens via python web3. But I get an error "TRANSFER_FROM_FAILED" like this. I know why this error comes up and I know i need to set up Slippage Tolerance somewhere. Can you guys let me know how can I put 49.99% Slippage Tolerance in there?
Regards.
pancakeswap2_txn = contract.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenValue ,0,
[contract_id, spend],
sender_address,
(int(time.time()) + 1000000)
).buildTransaction({
'from': sender_address,
'gasPrice': web3.toWei('5','gwei'),
'nonce': web3.eth.get_transaction_count(sender_address),
})
tokenValue ,0,
when you transfer 0 parameter, it means that "I want to get with minimum is zero amount", so if you want to get with slippage tolerance like 49%, you need to expect how much token B you will get after trade token A, there is one simple way to tradejust do some calculate min_token you receive instead of put it 0. here is my simple code of get min token.