This paper is centered on establishing a secure framework for the optimal concurrent operation of a smart city, encompassing transportation, water, heat, electrical, and cooling energy systems. The studied smart city includes the microgrid, smart transportation system (STS), energy hub (EH) and smart grid. In this regard, a subway synergism hub (SSH) as a new non-energy system is added to the smart city with the aim of serving the subway's water, heat, electrical and cooling demands as well as diminishing the operation cost of the smart city. The EH within the SSH cooperated with a desalination unit is considered to supply the subway's stations water demand by using the sea water. The investigation of the optimal allocation of the SSH unit for reducing the cost of smart city operation is also conducted by introducing a novel intelligent priority selection (IPS) analytical algorithm. In comparison to common meta-heuristic algorithms for allocation problems, the accurate optimal solution can be found in low runtime by the IPS algorithm. To achieve an accurate model of the smart city, directed acyclic graph (DAG) based blockchain approach is provided which can enhance the data and energy exchanges security within the smart city. This research paper introduces a security framework deployed in a smart city setting to establish a secure platform for energy transactions. The findings validate the effectiveness of this model and highlight the value of the IPS method. The effectiveness of the suggested approach has been assessed using the smart city system is comprised of various sections, including EVs, smart grid, microgrid, and SSH, demonstrating the credibility and accuracy of this study.