The development of 5G network communication has brought technological innovation to smart city communication, making the realization of V2X (vehicle to everything) technology possible. Vehicles wirelessly communicate with other vehicles, sensors, pedestrians, and roadside units, raising data security issues while driving. In order to ensure driving safety, the risk map cognitive model is established with the help of blockchain technology. In this model, the key map data and personal privacy information are encrypted and uploaded to form a blockchain, and the smart contract technology is used for automatic script processing. Then, according to different risk scenarios, cognitive learning is carried out for different risk levels, the cognitive results and corresponding operations are fed back to the intelligent vehicle, and these operations ensure the safe operation of the vehicle according to the intelligent vehicle. Finally, the feasibility of the model was verified by comparing different dangerous scenarios. The experimental results show that this risk cognition model can cognize the data of the intelligent vehicle according to different danger scenarios, and the model can transmit acceleration, deceleration, braking, and other behaviors to the intelligent vehicle to ensure smart city driving safety.