import asyncio
import aiohttp

bscscan_api_key = '<TRUFFLEHOG_REDACTED_BSCSCAN>'

# Create a semaphore with a limit of n
semaphore = asyncio.Semaphore(5)

async def get_transactions_from_block(block_number, session):
    async with semaphore:
        url = f'https://api.bscscan.com/api?module=proxy&action=eth_getBlockByNumber&tag={block_number}&boolean=true&apikey={bscscan_api_key}'
        try:
            async with session.get(url) as response:
                data = await response.json()
        except Exception as e:
            print(f'Error in API request: {e}')
            return []

        if data['result'] is None or isinstance(data['result'], str):
            print(f"Error: Cannot find the block")
            return []

        return data['result'].get('transactions', [])

async def get_newly_created_contracts(start_block, end_block):
    contract_list = []

    async def process_block(block_number_int):
        block_number = hex(block_number_int)
        transactions = await get_transactions_from_block(block_number, session)

        filter_address = '0x863b49ae97c3d2a87fd43186dfd921f42783c853'
        return [tx for tx in transactions if tx['isError'] == '0' and tx['contractAddress'] != '' and tx['from'] == filter_address]

    async with aiohttp.ClientSession() as session:
        tasks = [process_block(block_number) for block_number in range(start_block, end_block + 1)]
        results = await asyncio.gather(*tasks)

    for contracts in results:
        contract_list.extend(contracts)

    return contract_list

def display_new_contracts(start_block, end_block):
    loop = asyncio.get_event_loop()
    contracts = loop.run_until_complete(get_newly_created_contracts(start_block, end_block))

    if not contracts:
        print('No new contracts found.')
    else:
        print(f'Newly created smart contracts between blocks {start_block} and {end_block}: ')
        for contract in contracts:
            print(f"Block: {contract['blockNumber']} - Address: {contract['contractAddress']}")

start_block = 28864500  # Replace with your desired start block
end_block = 28864999  # Replace with your desired end block

display_new_contracts(start_block, end_block)


The code above throws an error

C:\Users\AshotxXx\PycharmProjects\UNCX\Add_Liquidity_and_Lock\venv\Scripts\python.exe C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py 
Traceback (most recent call last):
  File "C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py", line 58, in <module>
    display_new_contracts(start_block, end_block)
  File "C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py", line 46, in display_new_contracts
    contracts = loop.run_until_complete(get_newly_created_contracts(start_block, end_block))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AshotxXx\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py", line 37, in get_newly_created_contracts
    results = await asyncio.gather(*tasks)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py", line 33, in process_block
    return [tx for tx in transactions if tx['isError'] == '0' and tx['contractAddress'] != '' and tx['from'] == filter_address]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AshotxXx\PycharmProjects\UNCX\Project1\main.py", line 33, in <listcomp>
    return [tx for tx in transactions if tx['isError'] == '0' and tx['contractAddress'] != '' and tx['from'] == filter_address]
                                         ~~^^^^^^^^^^^
KeyError: 'isError'

Process finished with exit code -1073741819 (0xC0000005)

Fix it