<p>Yes, <code>Constraints.mustForgeValue</code> and <code>Constraints.mustPayToTheScript</code> are used to define/create a transaction that forges tokens or locks tokens in your script respectively (<a href="https://youtu.be/6VbhY162GQA?t=1720" rel="nofollow noreferrer">https://youtu.be/6VbhY162GQA?t=1720</a>).</p>
<p>There are multiple script types that validate different aspects of a transaction.</p>
<p>If you want to spend funds locked in a script(address) you need a validator script (Plutus.V1.Ledger.Scripts.Validator) that will validate any transaction consuming the UTXOs locked in that script. To lock funds in a script you need to transfer funds to that script, thus creating a new UTXO that is owned by the script.</p>
<p>If you want to forge tokens in a transaction you need a minting policy script (Plutus.V1.Ledger.Scripts.MonetaryPolicy) which validates that the forged tokens adhere to the specified policy. Minting policy scripts don't have a Datum and Redeemer available, because the transaction is not consuming a UTXO locked in the minting policy. I don't think sending funds to a minting policy makes sense or is even possible.</p>
<p>In your case you might want to have two scripts:</p>
<ul>
<li>MonetaryPolicy: validates the minting transaction</li>
<li>Validator: A script that manages funds created from minting</li>
</ul>
<p>The minting policy then has to make sure that the adequate amount of ada is being transferred to the fund-managing-script when validating the minting transaction.</p>
<p>When creating the minting transaction you can use <code>Constraints.mustPayToOtherScript</code> to send funds to the script.</p>

CC BY-SA 4.0
2021-05-23T22:06:40.473Z
2021-05-23T22:06:40.473Z
tobxy123
<p>As far as my understanding token with some amount can be forged by using this constraints.</p>
<pre><code>Constraints.mustForgeValue SomeValue
</code></pre>
<p>And ada can be locked into smart contract using mustPayToTheScript if i am not wrong.</p>
<p>So how to validate this transaction where some ada can be deposited to the contract and contract forges the equivalent amount of tokens according to the amount of ada locked in smart contract.</p>

<plutus>
How to validate transaction where number of tokens are generated based on the value locked in a contract?
# How to validate transaction where number of tokens are generated based on the value locked in a contract?

(Asked by: username_0 on 2021-05-23)

As far as my understanding token with some amount can be forged by using this constraints.
Constraints.mustForgeValue SomeValue

And ada can be locked into smart contract using mustPayToTheScript if i am not wrong.
So how to validate this transaction where some ada can be deposited to the contract and contract forges the equivalent amount of tokens according to the amount of ada locked in smart contract.

**Tags:** plutus

---

## 1 answers

### Answer by username_1 on 2021-05-23. Score: 4 | Accepted answer

Yes, `Constraints.mustForgeValue` and `Constraints.mustPayToTheScript` are used to define/create a transaction that forges tokens or locks tokens in your script respectively (<https://youtu.be/6VbhY162GQA?t=1720>).

There are multiple script types that validate different aspects of a transaction.

If you want to spend funds locked in a script(address) you need a validator script (Plutus.V1.Ledger.Scripts.Validator) that will validate any transaction consuming the UTXOs locked in that script. To lock funds in a script you need to transfer funds to that script, thus creating a new UTXO that is owned by the script.

If you want to forge tokens in a transaction you need a minting policy script (Plutus.V1.Ledger.Scripts.MonetaryPolicy) which validates that the forged tokens adhere to the specified policy. Minting policy scripts don't have a Datum and Redeemer available, because the transaction is not consuming a UTXO locked in the minting policy. I don't think sending funds to a minting policy makes sense or is even possible.

In your case you might want to have two scripts:

* MonetaryPolicy: validates the minting transaction
* Validator: A script that manages funds created from minting

The minting policy then has to make sure that the adequate amount of ada is being transferred to the fund-managing-script when validating the minting transaction.

When creating the minting transaction you can use `Constraints.mustPayToOtherScript` to send funds to the script.


---

