With the recent technological advancements, it has become possible to conceive numerous valuable applications for efficient utilization of energy resources in a smart grid. As distributed energy generation and distributed storage systems become cost-effective, trading energy becomes a lucrative alternative for both prosumers and manufacturers. In this paper, we make use of fuzzy logic to propose a system for optimal energy trading in a fog-enabled smart grid set-up. The existing systems in this realm have inherited issues of network latency, computational expensiveness, information availability, scalability, and performance. Some systems require a specialized transmission line for energy trading and plenty of them based on the dedicated producer-consumer model, putting limits to their practical effectiveness. Our framework makes use of fog-computing infrastructure to address scalability, information availability, and network latency issues. We exploit the fuzzy logic paradigm to handle the issues with crisp values and to improve the computational efficiency of the system. Our model of energy-trading system incorporates various input parameters to decide on the excess energy, including real-time price, time of day, outdoor temperature, buyers’ interest, and storage capacity. Simulation results show that our proposed system possesses promising potential to maximize the profit of energy trading and to minimize electricity usage from the main grid.