With the escalation of fossil fuel pollution and the challenges of climate change, the smart grid is forced to address the carbon emissions associated with fossil fuel use. Real-time pricing of smart grid is an effective means to regulate the balance of supply and demand in the grid as well as to achieve energy conservation and environmental protection. This paper takes traditional fossil energy and clean energy power supply as the background, takes social welfare maximization as the goal, combines carbon emission cost with traditional power generation cost, and constructs a real-time pricing model that takes into account carbon emission cost, so that thermal power enterprises participate in the power market and carbon market at the same time. By using duality methods, we transformed the original optimization problem into an equivalent one. Furthermore, a distributed iterative algorithm based on the subgradient projection method is employed to solve the dual problem. The simulation results verify the feasibility and effectiveness of the proposed real-time pricing strategy.