1

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.

1 Answer 1

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. It heavily uses the serialization lib to provide the different information required by this wallet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.