<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.sstatic.net/GudMD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GudMD.png" alt="enter image description here" /></a></p>
<p>Hope this will be useful.</p>

CC BY-SA 4.0
2022-02-26T13:32:23.297Z
Yes! Solved it thanks :)
John_Bones
CC BY-SA 4.0
2022-02-26T14:51:30.293Z
@John_Bones more than welcome!
kindofdev
CC BY-SA 4.0
2022-02-25T13:30:22.570Z
2022-02-25T13:49:32.107Z
2022-02-25T13:49:32.107Z
kindofdev
<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>

CC BY-SA 4.0
2022-02-25T12:47:54.200Z
Is ADA what you want to pay to the script?
kindofdev
<plutus><smart-contract>
Plutus: Integer->Value?
# Plutus: Integer->Value?

(Asked by: username_0 on 2022-02-25)

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)

**Tags:** plutus, smart-contract
> **Comments:**
> **username_1**: Is ADA what you want to pay to the script?  

---

## 1 answers

### Answer by username_1 on 2022-02-25. Score: 2 | Accepted answer

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.

> **Comments:**
> **username_0**: Yes! Solved it thanks :)  
> **username_1**: @John_Bones more than welcome!  

---

