<p>Be careful not to confuse metadata and datum, as they are different things. Metadata are part of a transaction, while a datum is part of an UtxO.</p>
<p>Metadata are completely optional and to the discretion of the transaction issuer, while the datum is mandatory when dealing with script addresses.</p>
<p>Some metadata can optionally be attached to a transaction independently of your decision to add some datum to the different UtxO. In addition, you don't send the datum directly, but its hash.</p>
<p>It is only when you want an UtxO back from a script that you have to provide a datum whose hash has to match with the one you defined previously.</p>
<p>This datum will then be part of the script context, as long a additional data you can provide through redeemers.</p>
<p>So, you can indeed record the datum intended for the script in the transaction metadata, but it not mandatory. It is just a mechanism to recover the correct information in case it is not possible otherwise.</p>
<p>Now, for the &quot;how to do that ?&quot;, the best is to study some open source code, like the one for the <a href="https://github.com/Berry-Pool/spacebudz/blob/3c1700b686677f9f87a5f8c78d3eb9029774dd32/src/cardano/market/index.js#L397-L436" rel="nofollow noreferrer">SpaceBudz market</a>. It heavily uses the <a href="https://github.com/Emurgo/cardano-serialization-lib" rel="nofollow noreferrer">serialization lib</a> to provide the different information required by this wallet.</p>

CC BY-SA 4.0
2022-01-11T17:30:00.760Z
2022-01-11T17:30:00.760Z
Jean-Sébastien Gonsette
<p>Datum is hashed and assigned to an UTXO</p>
<p>When you send the transaction you can add optional parameters like metadata and/or datum
datum is used by smart contract since it's the only data that smart contract can see.</p>
<p>So in short:</p>
<ol>
<li>Send the transaction to the address</li>
<li>Add json to metadata</li>
<li>Convert the json to datum and add to UTXO</li>
</ol>
<p>how to implement &quot;Convert the json to datum and add to UTXO&quot; using NAMI wallet.</p>

<datum><nami>
How to add datum to UTXO in nami
# How to add datum to UTXO in nami

(Asked by: username_0 on 2022-01-07)

Datum is hashed and assigned to an UTXO

When you send the transaction you can add optional parameters like metadata and/or datum
datum is used by smart contract since it's the only data that smart contract can see.

So in short:

1. Send the transaction to the address
2. Add json to metadata
3. Convert the json to datum and add to UTXO

how to implement "Convert the json to datum and add to UTXO" using NAMI wallet.

**Tags:** datum, nami

---

## 1 answers

### Answer by username_1 on 2022-01-11. Score: 1

Be careful not to confuse metadata and datum, as they are different things. Metadata are part of a transaction, while a datum is part of an UtxO.

Metadata are completely optional and to the discretion of the transaction issuer, while the datum is mandatory when dealing with script addresses.

Some metadata can optionally be attached to a transaction independently of your decision to add some datum to the different UtxO. In addition, you don't send the datum directly, but its hash.

It is only when you want an UtxO back from a script that you have to provide a datum whose hash has to match with the one you defined previously.

This datum will then be part of the script context, as long a additional data you can provide through redeemers.

So, you can indeed record the datum intended for the script in the transaction metadata, but it not mandatory. It is just a mechanism to recover the correct information in case it is not possible otherwise.

Now, for the "how to do that ?", the best is to study some open source code, like the one for the [SpaceBudz market](https://github.com/Berry-Pool/spacebudz/blob/3c1700b686677f9f87a5f8c78d3eb9029774dd32/src/cardano/market/index.js#L397-L436). It heavily uses the [serialization lib](https://github.com/Emurgo/cardano-serialization-lib) to provide the different information required by this wallet.


---

