In this paper, an Internet of Energy (IoE) solution for providing optimal charging and control of resources in the era of electric vehicles (EVs) with energy trading and security is considered. A blockchain based security solution is presented by considering the IoE as a distributed energy system with internet of things (IoT). However, by inheriting the security concerns of IoTs, IoE also faces the security challenges and is considered here. Hierarchical key generation is used for cryptographic keys, based on lattice constructions. Along with a consensus tailored with Practical Byzantine Fault Tolerance (PBFT), an additional smart contract is also applied for utilization of energy transfer. The presented solution provides transparency, reliability, availability and failure recovery inheriting from the blockchain aspects. To the best of our knowledge, the present study is the first attempt in this direction of IoE-EV interface solutions. The experimental results, comparative analysis and security validation affirm the superiority of the proposed solution over the existing approaches.