user127: I changed transition function in Lecture 7 and added constraint for minting Constraints.mustMintValue:
transition ts s r = case (stateValue s, stateData s, r) of
    (v, _, SetPrice p)   | p >= 0           -> Just ( Constraints.mustBeSignedBy (tsSeller ts) <>
                                                      Constraints.mustMintValue (assetClassValue (tsToken ts) 100)
                                                    , State p v
                                                    )

When I start emulator trace monad I am getting error in log:
Slot 00007: *** CONTRACT LOG: "SMCContractError (ConstraintResolutionError (MintingPolicyNotFound aa))"

I tried also with a different currencyPolicy than "aa", the real one that I got from Lecture 5 - Free.hs but I am getting the same result.
What is the proper way to do minting from State Machine?

user5822: I had this exact same issue with a StateMachine. I solved it by using runStepWith instead of runStep, which allows you to also supply the minting policy.
See the haddock documentation for details on how to use runStepWith

127: <p>I changed <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/1ab1d5c11a94da0b709ad05f921d91795a2fc209/code/week08/src/Week08/TokenSale.hs#L63" rel="nofollow noreferrer">transition function in Lecture 7</a> and added constraint for minting Constraints.mustMintValue:</p>
<pre><code>transition ts s r = case (stateValue s, stateData s, r) of
    (v, _, SetPrice p)   | p &gt;= 0           -&gt; Just ( Constraints.mustBeSignedBy (tsSeller ts) &lt;&gt;
                                                      Constraints.mustMintValue (assetClassValue (tsToken ts) 100)
                                                    , State p v
                                                    )
</code></pre>
<p>When I start emulator trace monad I am getting error in log:</p>
<pre><code>Slot 00007: *** CONTRACT LOG: &quot;SMCContractError (ConstraintResolutionError (MintingPolicyNotFound aa))&quot;
</code></pre>
<p>I tried also with a different currencyPolicy than &quot;aa&quot;, the real one that I got from Lecture 5 - Free.hs but I am getting the same result.</p>
<p>What is the proper way to do minting from State Machine?</p>
 5822: <p>I had this exact same issue with a StateMachine. I solved it by using <code>runStepWith</code> instead of <code>runStep</code>, which allows you to also supply the minting policy.</p>
<p>See <a href="https://playground.plutus.iohkdev.io/doc/haddock/plutus-contract/html/Plutus-Contract-StateMachine.html#:%7E:text=lookups%20for%20transaction.-,runStepWith,Source,-%23" rel="nofollow noreferrer">the haddock documentation</a> for details on how to use <code>runStepWith</code></p>
