In recent years, peer to peer energy trading have become an important component of local and decentralized electricity markets. One of the remarkable challenges in implementing these trades between users is keeping the technical constraints of distribution networks within the permitted limits and utilizing the maximum capacity of prosumers during energy transactions. Usually, power demand at points in the grid that do not have generations varies over time, which makes it very difficult for prosumers to determine their operating range. In this paper, a structure based on dynamic operation envelopes is presented to dynamically calculate network constraints, which, in addition to maintaining the technical constraints of the network within the permitted range, allows the maximum use of the capacity of prosumers to participate in the market. The proposed structure is presented for P2P trades of energy communities consisting of solar and wind generation, fixed and flexible loads, and batteries in an active distribution network. Also, in this structure, dynamic operation envelopes are calculated from the agreement between the energy communities and the distribution system operator. The proposed method has been implemented on standard IEEE 33 bus system with the presence of several energy communities. The optimization of the equations is performed using the alternating direction method of multipliers (ADMM) and is completely decentralized. The simulations in this paper are accomplished using GAMS software version 24. 8. 1., and the obtained results show that the presented method increases the trades of energy communities and maintains the technical constraints of the network within the safe range.