Xuling Huo, Zhiwei Xun
This paper presents a secure and efficient peer-to-peer (P2P) energy trading framework for interconnected microgrids using blockchain technology and multi-agent optimization. A dynamic pricing mechanism is developed to enable real-time negotiation between prosumers and consumers under both islanded and grid-connected conditions, ensuring fair and balanced energy exchange. To guarantee transaction integrity, a two-stage blockchain consensus protocol is proposed, significantly reducing validation time and communication overhead compared with traditional consensus mechanisms. The energy trading optimization problem is solved using the Modified Jellyfish Search Optimizer (M-JSO), which enhances local exploitation and global exploration to achieve optimal scheduling and resource allocation. The proposed approach is validated on an IEEE 33-bus test system, demonstrating continuous energy trading across 24 h of operation, even under the intermittency of renewable generation. Simulation results show that the model minimizes load-shedding costs, improves network reliability, and scales linearly with the number of participating microgrids. Additionally, sensitivity analysis confirms that increasing the number of microgrids boosts trading volume and overall system efficiency while maintaining computational feasibility. This work contributes a holistic solution that integrates secure blockchain settlement, decentralized optimization, and dynamic market mechanisms, paving the way for resilient, transparent, and economically viable energy exchange networks.