This paper presents an optimal distributed approach for transactive energy sharing in residential microgrids. A mixed-integer linear programming (MILP) problem is formulated to optimize energy sharing tasks of different types of residential houses along with the reduction in total operational costs as well as optimal charging and discharging of energy storages. In this paper, the energy sharing problem is first formulated as a centralized optimization problem and then decomposed into one master problem and two sub-problems in order to reduce the computational burden and avoid sharing private information of customers. The proposed distributed energy sharing framework based on the MILP is evaluated on a residential microgrid in terms of analyzing energy utilization (both renewable energy sources and energy storages) and cost-benefits while the computational efficiency is evaluated through the convergence speed. Analytical results clearly reflect the effectiveness and efficiency of the proposed optimal distributed energy sharing framework.