Selling tokens and get BNB instead of wBNB?

Question:

I made a function that sells a token in the BSC smartchain. However, I want to receive it in BNB directly instead of wBNB. How can I unwrap the wBNB I receive?

def sell_drdc(wallet_address, token_address, wallet_no):
    if not is_approved(token_address):
        approve(wallet_address, private_key)
    erc20 = web3.eth.contract(token_address, abi=erc20Abi)
    token_value = erc20.functions.balanceOf(wallet_address).call()
    if token_value != 0:
    pancakeswap2_txn = router.functions.swapExactTokensForTokensSupportingFeeOnTransferTokens (token_value, 0, [DRDC_Address, wbnb_contract], wallet_address, (int(time()) + 900)).buildTransaction({
                'from': wallet_address,
                'nonce': web3.eth.get_transaction_count(wallet_address),
            })
    signed_txn = web3.eth.account.sign_transaction(pancakeswap2_txn, private_key=private_key)
    try:
        tx_token = web3.eth.send_raw_transaction(signed_txn.rawTransaction)
        web3.eth.waitForTransactionReceipt(tx_token, timeout=900)
        display_success() # Just function that sends success message
        update_text()
    except ValueError:
        display_error() # Just a function that sends the error
    except UnboundLocalError:
        sell_drdc(wallet_address, token_address, wallet_no) # Attempts to repeat if something goes wrong
Asked By: Austin

||

Answers:

I managed to see what’s wrong, It should be

swapExactTokensForETHSupportingFeeOnTransferTokens
Answered By: Austin