<p>I'm not sure in what context you need to append metadata to a transaction, but you may want to check <a href="https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Constraints-TxConstraints.html" rel="nofollow noreferrer">this documentation</a> for any of these helper functions used for creating <code>TxContraints</code>:</p>
<ul>
<li><code>mustIncludeDatum :: forall i o. Datum -&gt; TxConstraints i o</code></li>
<li><code>mustPayToOtherScript :: forall i o. ValidatorHash -&gt; Datum -&gt; Value -&gt; TxConstraints i o</code></li>
<li><code>mustPayToTheScript :: forall i o. IsData o =&gt; o -&gt; Value -&gt; TxConstraints i o</code></li>
</ul>
<p>The first two require a <code>Datum</code> while the last one could be any arbitrary data type converted to a <code>Data</code> using <code>PlutusTx.unstableMakeIsData</code> or its equivalents.</p>
<p>EDIT:</p>
<p>You might want to look into <code>StateMachine</code>s. Especially the transition function (which also requires <code>TxConstraints</code>). <a href="https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-contract/html/Plutus-Contract-StateMachine-OnChain.html" rel="nofollow noreferrer">You may start with this documentation</a>,</p>

CC BY-SA 4.0
2021-07-12T07:36:19.007Z
Aoaddeola, I am no referring to the data embedded in the UTXO as Datum, I am referring to this: https://iohk.io/en/blog/posts/2020/11/03/getting-to-grips-with-metadata-on-cardano/
AngelCastillo
CC BY-SA 4.0
2021-07-09T14:36:50.647Z
2021-07-11T14:49:38.133Z
2021-07-11T14:49:38.133Z
Aoaddeola
<p>No, it is not possible right now.</p>
<p>To change that, we would need a hard fork introducing this functionality.</p>

CC BY-SA 4.0
2021-11-18T19:37:44.013Z
Why would this require a hard fork?. This is off-chain code, is just a matter of serializing the metadata and appending it to the transaction. Or am I missing something?
AngelCastillo
CC BY-SA 4.0
2021-11-17T12:18:46.807Z
2021-11-17T12:18:46.807Z
Marek Mahut - StakeNuts
<p>Is there a way to append metadata to transactions that are send from plutus code?</p>
<p>Right now we send transactions from the contracts like follows (or something alike):</p>
<pre><code>ledgerTx &lt;- submitTxConstraintsWith @Cube constraints tx
void $ awaitTxConfirmed $ txId ledgerTx
</code></pre>
<p>I know Alonzo is still in development/testing phase, but I was wondering if there is already something in the API do this or there will be (I cant find anything in the code base as of right now).</p>

CC BY-SA 4.0
2021-07-29T13:25:30.820Z
AngelCastillo -  just wondering if you ever got anywhere with this? I'm currently looking into the same requirement.
William
CC BY-SA 4.0
2021-07-30T04:39:00.830Z
Not yet, haven't found any info regarding this. I hope by the time we can access the test net to test our dapps, there is some information.
AngelCastillo
CC BY-SA 4.0
2022-02-11T11:01:07.473Z
Any Updates on how to achieve this ?
Dawar Ejaz
CC BY-SA 4.0
2022-04-28T05:25:32.387Z
Should one of the answers be marked as accepted?
gRebel
CC BY-SA 4.0
2022-04-28T11:42:05.687Z
None of the answers provided so far are correct
AngelCastillo
<plutus><metadata>
Append metadata to transaction from Plutus code
# Append metadata to transaction from Plutus code

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

Is there a way to append metadata to transactions that are send from plutus code?
Right now we send transactions from the contracts like follows (or something alike):
ledgerTx <- submitTxConstraintsWith @Cube constraints tx
void $ awaitTxConfirmed $ txId ledgerTx

I know Alonzo is still in development/testing phase, but I was wondering if there is already something in the API do this or there will be (I cant find anything in the code base as of right now).

**Tags:** plutus, metadata
> **Comments:**
> **username_1**: AngelCastillo -  just wondering if you ever got anywhere with this? I'm currently looking into the same requirement.  
> **username_0**: Not yet, haven't found any info regarding this. I hope by the time we can access the test net to test our dapps, there is some information.  
> **username_2**: Any Updates on how to achieve this ?  
> **username_3**: Should one of the answers be marked as accepted?  
> **username_0**: None of the answers provided so far are correct  

---

## 2 answers

### Answer by username_4 on 2021-07-09. Score: 2

I'm not sure in what context you need to append metadata to a transaction, but you may want to check [this documentation](https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-ledger/html/Ledger-Constraints-TxConstraints.html) for any of these helper functions used for creating `TxContraints`:

* `mustIncludeDatum :: forall i o. Datum -> TxConstraints i o`
* `mustPayToOtherScript :: forall i o. ValidatorHash -> Datum -> Value -> TxConstraints i o`
* `mustPayToTheScript :: forall i o. IsData o => o -> Value -> TxConstraints i o`

The first two require a `Datum` while the last one could be any arbitrary data type converted to a `Data` using `PlutusTx.unstableMakeIsData` or its equivalents.

EDIT:

You might want to look into `StateMachine`s. Especially the transition function (which also requires `TxConstraints`). [You may start with this documentation](https://alpha.marlowe.iohkdev.io/doc/haddock/plutus-contract/html/Plutus-Contract-StateMachine-OnChain.html),

> **Comments:**
> **username_0**: Aoaddeola, I am no referring to the data embedded in the UTXO as Datum, I am referring to this: https://iohk.io/en/blog/posts/2020/11/03/getting-to-grips-with-metadata-on-cardano/  

---

### Answer by username_5 on 2021-11-17. Score: 1

No, it is not possible right now.

To change that, we would need a hard fork introducing this functionality.

> **Comments:**
> **username_0**: Why would this require a hard fork?. This is off-chain code, is just a matter of serializing the metadata and appending it to the transaction. Or am I missing something?  

---

