The recent spike in microgeneration of renewable energy is demanding a smart, reliable, secured and efficient technology to enable Peer to Peer (P2P) energy trading. Due to the inherent characteristics, blockchain has been a preferred technology for realizing P2P energy trading. However, blockchain implementations for P2P energy trading so far are suffering from critical challenges such as security, privacy and scalability. In this paper, we introduce a P2P energy trading platform that leverages the popular blockchain technology and addresses these concerns. In particular, a multilayered semi-permissioned blockchain based platform along with a Quality of Transaction (QoT) module is proposed as a trading platform that can be used for transaction of energy. A two stage blockchain architecture, backed by QoT, ensures proper verification and validation of the participants and transactions. We present two use cases that demonstrate two different attack scenarios to highlight the resiliency of the proposed framework. Finally, a qualitative analysis shows the effectiveness of the system with respect to security, privacy and scalability.