Environmental factors and electronic interference often disrupt communication between UAV swarms and ground control centers, requiring UAVs to complete missions autonomously in offline conditions. However, current coordination schemes for UAV swarms heavily depend on ground control, lacking robust mechanisms for offline task allocation and coordination, which compromises efficiency and security in disconnected settings. This limitation is especially critical for complex missions, such as rescue or attack operations, underscoring the need for a solution that ensures both mission continuity and communication security. To address these challenges, this paper proposes an offline task-coordination algorithm based on blockchain smart contracts. This algorithm integrates task allocation, resource scheduling, and coordination strategies directly into smart contracts, allowing UAV swarms to autonomously make decisions and coordinate tasks while offline. Experimental simulations confirm that the proposed algorithm effectively coordinates tasks and maintains communication security in offline states, significantly enhancing the swarm’s autonomous performance in complex, dynamic scenarios.