Due to the widespread deployment of distributed energy resources, renewable energies and battery energy storage, the peer to peer (P2P) energy trading schematic has gained the staple attention for improving the energy efficiency and energy flexibility of power grids. This is while, smart demand response programming (DRP) is considered as the bridge between these two indicators of smart grid. Moreover, the subtle point of proliferating P2P schematics is the regulation towards the maximization of social welfare leading to economic profitability of customers and owner’s of microgrid and, eventually, reduction of pollutant emission of fossil fuels. Also, uncertainty, aroused by electrical consumption and renewable energy resources, is the core of every considerations, which has to be dealt with intelligent algorithms for strengthening the stability of transactions. On the other hand, compatibility with upper grid’s regulations, i.e. power loss and voltage deviation, along with determining fair price of energy trading are the subjects of P2P-based tactics. Therefore, this paper proposes a P2P-based transactive energy sharing architecture, as two stage mixed integer non-linear programming, using smart DRP integrated with machine learning approach, i.e. radial basis neural network.Firstly, the uncertainty of electrical demand and renewable energies are relaxed through short term forecasting. Doing so, the day-ahead transactions of peers are obtained based on their energy management objective, targeting the energy reliability of customers, which energy not supplied criterion has to be equal to zero. Then, participation of customers in DRP, cost of customers, revenue of microgrid’s owner and transactions of real time programming are optimally acquired based on Pareto front technique. Also, the simulations are conducted on IEEE 85 bus test system to realize the considerations. The results convey that the profitability of customers and owners is tied with the implementation of smart DRP and accurate forecasting of uncertain variables. In addition, the maximum improvements towards maximizing the revenue of owners and minimizing the cost of customers take place at hours which the electrical consumption is shifted from peaks to off-peaks and mid-peaks, certifying the performance of proposed methodology.