'Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'
I'm trying to create a script to sell token on pancakeswap and cant seem to get it to work.
I'm able to buy just fine but cannot sell.
I'm getting Fail with error 'TransferHelper: TRANSFER_FROM_FAILED'
The script is a hit and miss with the balance of the tokens depending of the decimals. I just wish there was a way that I could put 100% of balance.
pancakeswap2_txn = contract.functions.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenValue, 0, [contract_id, spend],
sender_address,
(int(time.time()) + 1000000)
).buildTransaction({
'from': sender_address,
'gas': 1800000,
'gasPrice': web3.toWei(input("How much Gwei: "), 'gwei'),
'nonce': web3.eth.get_transaction_count(sender_address),
})
signed_txn = web3.eth.account.sign_transaction(pancakeswap2_txn, private_key = config.private)
tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
