With the rapid expansion of the world population and economy, the need for energy has also increased. To minimize energy waste, it is crucial that energy be supplied to residences and businesses in an efficient manner. Smart Grids (SG) have the potential to decrease these power losses by improving the energy grid's efficiency. The effective integration of methods like artificial intelligence and blockchain into SGs has made it easier to predict customer preferences. Immediate analysis and comparison of the different AI and blockchain approaches is necessary in order to determine which approach is best for SGs. This study aims to know about some basic of smart grid. Furthermore, this study also looks at different types of layers and attacks on these layers and provide solutions of these attacks using AI and blockchain methods. At the end the study, also focus on open issues in this field and gives some future directions. By classifying attacks, proposing innovative defenses, and exploring AI and blockchain solutions, the study contributes to safeguarding smart grid infrastructures. Future research directions include addressing emerging attack strategies and refining technology for enhanced security.