Smart grids incorporate IoT devices that enhance energy management, monitoring, and overall grid efficiency. However, this interconnectivity also increases vulnerability to cybersecurity threats, posing risks to critical infrastructure. This research investigates the implementation of blockchain technology to secure data transactions within IoT-based smart grids. By leveraging blockchain's decentralized, tamper-resistant characteristics, the study demonstrates improvements in data integrity and cybersecurity for smart grids, providing a potential framework for resilient and secure energy infrastructures.