user6634: I give to Integer via an endpoint function, multiply them and give them to
Constraints.mustPayToTheScript. For this I need the result to be converted into an Value. Does Anyone know how to do this?
 buy =  endpoint @"buy" @BuyParams $ \ (BuyParams fst scd ) -> do
    let amt = fst*scd
    let tx         = Constraints.mustPayToTheScript (hashString fst) amt
    void (submitTxConstraints gameInstance tx)


user6113: Supposing that you want to pay ADA to the script, you can use lovelaceValueOf :: Integer -> Value from Plutus.V1.Ledger.Ada as follows:
import qualified Plutus.V1.Ledger.Ada as Ada

buy = endpoint @"buy" @BuyParams $ \ (BuyParams fst scd ) -> do
   let amt = fst*scd
       val = Ada.lovelaceValueOf amt
       tx  = Constraints.mustPayToTheScript (hashString fst) val
   void (submitTxConstraints gameInstance tx)



Hope this will be useful.

6634: <p>I give to Integer via an endpoint function, multiply them and give them to
<code>Constraints.mustPayToTheScript</code>. For this I need the result to be converted into an <code>Value</code>. Does Anyone know how to do this?</p>
<pre><code> buy =  endpoint @&quot;buy&quot; @BuyParams $ \ (BuyParams fst scd ) -&gt; do
    let amt = fst*scd
    let tx         = Constraints.mustPayToTheScript (hashString fst) amt
    void (submitTxConstraints gameInstance tx)
</code></pre>
 6113: <p>Supposing that you want to pay <strong>ADA</strong> to the script, you can use <code>lovelaceValueOf :: Integer -&gt; Value</code> from <code>Plutus.V1.Ledger.Ada</code> as follows:</p>
<pre><code>import qualified Plutus.V1.Ledger.Ada as Ada

buy = endpoint @&quot;buy&quot; @BuyParams $ \ (BuyParams fst scd ) -&gt; do
   let amt = fst*scd
       val = Ada.lovelaceValueOf amt
       tx  = Constraints.mustPayToTheScript (hashString fst) val
   void (submitTxConstraints gameInstance tx)

</code></pre>
<p><a href="https://i.stack.imgur.com/GudMD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GudMD.png" alt="enter image description here" /></a></p>
<p>Hope this will be useful.</p>
