<p>Yes. It's important to have both options though.</p>
<p>Remember that the script address is derived from a hash of the compiled script code. So, if you parameterize parts of the script, the script address will be different with each parameter.</p>
<p>An example Lars gives in the PPP is an <a href="https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week05/src/Week05/NFT.hs#L35" rel="noreferrer">NFT</a>. If you parameterize the forging policy to take a specific UTxO, and that script consumes that UTxO, you guarantee that there is only one instance of that policy. Only the person who owned that UTxO could possibly create that token, thus guaranteeing the creation only happens once.</p>
<p>If you had the same UTxO field in the datum, any instantiator of the script could specify some UTxO they own <strong>and the script address would be the same</strong>. Since the Currency Symbol is in fact the Script Address, any caller could create duplicates of the token and those tokens would be <em>fungible</em>.</p>

CC BY-SA 4.0
2021-05-20T19:30:03.227Z
2021-05-21T16:25:19.823Z
2021-05-21T16:25:19.823Z
Mitchell Turner
<p>Are you proposing using <code>SomeDatum' = (SomeContractParam, SomeDatum)</code> in lieu of <code>SomeDatum</code> as the actual datum to use so that you can drop the <code>SomeContractParam</code> <code>mkValidator</code> argument?</p>
<p>If so, then here is a problem. It is easy to find all the UTXOs at an address (including script address), by using <code>utxoAt</code>, so when you have different script addresses associated with different <code>SomeContractParam</code> values, <code>utxoAt</code> will separate out the UTXOs for you by the <code>SomeContractParam</code>. If you use <code>(SomeContractParam, SomeDatum)</code> as the actual datum and one script address for handling all the different <code>SomeContractParam</code> values, you can't easily segregate the UTXOs by <code>SomeContractParam</code> especially when the blockchain stores only <code>DatumHash</code> and not <code>Datum</code>. So e.g. you can't easily specify &quot;spend UTXOs from among those that match a certain SomeContractParam&quot; -- you would have to lookup the datum of all the UTXOs somehow.</p>
<p>Furthermore you would have to include the datum in the ScriptLookups submitted for the transaction in order for the validator to get the <code>SomeContractParam</code> value from the datum, resulting in needing to encode the transaction request with more bytes.</p>

CC BY-SA 4.0
2021-05-20T17:23:46.797Z
2021-05-20T17:23:46.797Z
Joshua Chia
<p>While writing validation as:</p>
<pre><code>mkValidator :: SomeContractParam -&gt; SomeDatum -&gt; () -&gt; ScriptContext -&gt; Bool 
</code></pre>
<p>Could't we pass the same thing to Datum instead of using Contract Parameter?</p>

<plutus>
Why do we need parameterized contracts? Can't we just use datum?
# Why do we need parameterized contracts? Can't we just use datum?

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

While writing validation as:
mkValidator :: SomeContractParam -> SomeDatum -> () -> ScriptContext -> Bool 

Could't we pass the same thing to Datum instead of using Contract Parameter?

**Tags:** plutus

---

## 2 answers

### Answer by username_1 on 2021-05-20. Score: 9

Yes. It's important to have both options though.

Remember that the script address is derived from a hash of the compiled script code. So, if you parameterize parts of the script, the script address will be different with each parameter.

An example Lars gives in the PPP is an [NFT](https://github.com/input-output-hk/plutus-pioneer-program/blob/main/code/week05/src/Week05/NFT.hs#L35). If you parameterize the forging policy to take a specific UTxO, and that script consumes that UTxO, you guarantee that there is only one instance of that policy. Only the person who owned that UTxO could possibly create that token, thus guaranteeing the creation only happens once.

If you had the same UTxO field in the datum, any instantiator of the script could specify some UTxO they own **and the script address would be the same**. Since the Currency Symbol is in fact the Script Address, any caller could create duplicates of the token and those tokens would be *fungible*.


---

### Answer by username_2 on 2021-05-20. Score: 2

Are you proposing using `SomeDatum' = (SomeContractParam, SomeDatum)` in lieu of `SomeDatum` as the actual datum to use so that you can drop the `SomeContractParam` `mkValidator` argument?

If so, then here is a problem. It is easy to find all the UTXOs at an address (including script address), by using `utxoAt`, so when you have different script addresses associated with different `SomeContractParam` values, `utxoAt` will separate out the UTXOs for you by the `SomeContractParam`. If you use `(SomeContractParam, SomeDatum)` as the actual datum and one script address for handling all the different `SomeContractParam` values, you can't easily segregate the UTXOs by `SomeContractParam` especially when the blockchain stores only `DatumHash` and not `Datum`. So e.g. you can't easily specify "spend UTXOs from among those that match a certain SomeContractParam" -- you would have to lookup the datum of all the UTXOs somehow.

Furthermore you would have to include the datum in the ScriptLookups submitted for the transaction in order for the validator to get the `SomeContractParam` value from the datum, resulting in needing to encode the transaction request with more bytes.


---

