Traffic flow prediction is the an important issue in the field of intelligent transportation, and real-time and accurate traffic flow prediction plays a crucial role in improving the efficiency of traffic networks. Existing traffic flow prediction methods use deep learning models and collected traffic flow datasets to predict traffic flow. These datasets contain the private data of clients, so if some clients are unwilling to participate in the traffic flow prediction, the traffic flow prediction results will be inaccurate. Therefore, it is important to address the issue that how to motivate clients to actively participate in the traffic flow prediction while protecting the privacy data. So, this paper proposes a traffic flow prediction method based on blockchain and federated learning (TFPM-BFL). Firstly, the traffic flow prediction problem is described as federated learning (FL) task, the improved long and short-term memory (LSTM) model is used to predict the traffic flow at the client side, the traffic flow data is decomposed by wavelet function, and the LSTM network with added attention mechanism is used to obtain traffic flow prediction results; Then, incentive mechanism based on reputation value is proposed, the model parameters are uploaded to the blockchain for local and partial reputation evaluation through smart contracts, and the corresponding global reputation update is obtained, the reward is distributed to clients according to global reputation, so the clients are motivated to participate in the traffic flow prediction; Finally, the model aggregation method based on reputation value and compression rate is designed. Based on the reputation evaluation results, the edge server uses the Topk algorithm to perform high-quality aggregation of the local model parameters uploaded by clients (roadside units), central server aggregates the partial model parameters from edge server, and then the central server distributes the global aggregated model parameters to clients to perform the next round of FL. By using the FL framework, TFPM-BFL uploads the model parameters instead of the original traffic flow data, so it can protect private data. Moreover, it can provide incentive mechanism through reputation evaluation and reward to encourage clients to participate in the FL task. Simulation results show that TFPM-BFL can realize accurate and timely traffic flow prediction, and it can effectively motivate clients to participate in FL task while ensuring the privacy of the underlying data.