There are multiple conjectures relating the cohomological Hall algebras (CoHAs) of certain substacks of the moduli stack of representations of a quiver Q to the Yangian Y^{Q}_textrm{MO} by Maulik–Okounkov, whose construction is based on the notion of stable envelopes of Nakajima varieties. In this article, we introduce the cohomological Hall algebra of the moduli stack of framed representations of a quiver Q (framed CoHA), and we show that the equivariant cohomology of the disjoint union of the Nakajima varieties {mathcal {M}}_Q(text {v},text {w}) for all dimension vectors text {v} and framing vectors text {w} has a canonical structure of subalgebra of the framed CoHA. Restricted to this subalgebra, the algebra multiplication is identified with the stable envelope map. As a corollary, we deduce an explicit inductive formula to compute stable envelopes in terms of tautological classes.