unwrap_pls

Function

def unwrap_pls(account, amount, attempts=18):
    wpls_contract = load_contract("0xA1077a294dDE1B09bB078844df40758a5D0f9a27")
    tx = wpls_contract.functions.withdraw(to_token_decimals(amount, 18)).build_transaction({
        "from": account.address,
        "nonce": get_nonce(account.address)
    })
    try:
        return broadcast_transaction(account, tx, True, attempts)
    except Exception as e:
        if error := interpret_exception_message(e):
            logging.error("{} to unwrap PLS".format(error))
        return False

Description

  • Load the WPLS contract

  • Create a transaction to unwrap a specified amount

  • Broadcast the transaction and return True/False