An innovative approach to optimizing energy exchanges within an energy community is introduced through the implementation of a local blockchain. User privacy is protected, and comprehensive distributed optimization is ensured without the need for third-party intervention. Optimization is conducted using an Alternating Direction Method of Multipliers (ADMM) algorithm. This algorithm operates within the blockchain environment to facilitate consensus among users. Python clients, working within the blockchain, are employed for the local optimization of power profiles. Furthermore, a smart contract is deployed on the blockchain, acting as a critical tool to ensure that global constraints are adhered to. This approach underscores the pivotal role of blockchain in enabling distributed optimization and consensus within an energy community. Simulations are conducted to compare two distinct consensus mechanisms: Proof of Work and Proof of Authority. The energy consumption of the overall blockchain environment is measured and compared to a centralized situation. Findings indicate that for a limited number of nodes, both Proof of Work and Proof of Authority exhibit similar energy consumption levels. Compared to a centralized solution and specifically, for eight users, energy consumption of the blockchain is found to be 47% more. The research suggests that for a larger number of nodes, a local blockchain could potentially be more energy-efficient than a centralized solution for optimization. This insight presents a promising direction for the large-scale development of blockchain-based energy exchange mechanisms.