Since fog nodes are resource-constrained and imperfectly trusted heterogeneous devices, guaranteeing a real-time response to Internet of Things (IoT) tasks while optimizing system energy consumption remains a significant challenge. To overcome this, we first propose a acrlong DBC-enabled cloud–fog collaborative task scheduling architecture. Second, a task scheduling model is constructed to optimize system energy consumption and task deadline violation time while adhering to the IoT task response time restriction. Finally, two blockchain-enabled task scheduling algorithms are developed: 1) the reputation-based priority-aware algorithm (DB_RP) and 2) the accelerated ant colony system algorithm (DB_AACS). Extensive experiments are conducted to assess the proposed algorithm in four dimensions: 1) task completion rate; 2) system makespan; 3) system energy consumption; and 4) task deadline violation time. The experimental results demonstrate that the proposed algorithm is superior to the existing literature, and the acceleration strategy in DB_AACS is effective.