3

What is the best practice of storing the local state of an UTXO to be publicly visible on-chain?

Thinking about how application would function in the future I thought that in a good DeFi ecosystem all datums should be publicly deducible. That is, no intermediate should be needed to process the state. And since the hash function is a one way function there is no deducing what a hashed state represents.

Right now datums can only be send in a transaction as a hashed values right? The cardano-cli only supports building transactions with the command --tx-out-datum-hash. I do not know what the protocol allows at the moment, maybe it is allowed but the client won't construct such transactions for you. Now to overcome this one can send unhashed metadata with the transaction to publicly anounce the datum in the same transaction. I am missing some other way? This extra hashed datum is a bit redundant, though I know it is needed now since UTXO's with empty datums are unclaimable [1].

I think that the SpaceBudz auction contract is initiated in the above described way, metadata is send with every UTXO that is inbound of the script address [2]. I have not figured out how this metadata is correctly formatted to correspond to datumhash. More explicitly, I am yet to construct a json that hashes to the datum via the command cardano-cli transaction hash-script-data --script-data-file file.json.

Lastly I wonder in general what the impact is of these uncompressed metadata transaction. All plutus core code is serialized to hex and is transformed to CBOR before transacting. Would it be a good habit to do this for metadata as well? I have now idea what the PAB will do in this respect, maybe this is a no-brainer?

1 Answer 1

0

An other user on the Cardano forum answered this question, for ease of use I'll will post that answer here as well [1].

The protocol allows to embed datum into the witness set, though the current version of the cardano-cli does not support it. What, you can do is download the latest cli build from Hydra and use that one. Example:

cardano-cli transaction build --tx-out-datum-embed-file ... # or --tx-out-datum-embed-value

I highly encourage you to use only the precise JSON i.e. -file option instead of the causal one -value one.

But, what do you mean by uncompressed metadata transaction? The metadata in block is serialized from JSON to CBOR.

And

To clear the things a little bit. Datum hash is in the UTxO or as a map key in the witness set.

And yes a datum should not be act like an un-locking thing (that is why there is redeem) and should be publicly available all the time and or easily be reconstructed off chain. They only should be acting as state holders. iirc there was a discussion in the past whether the whole datum should be the part of the UTxO, but they (IOG) have decided not to go with that route for several reasons.

The problem is that in the current implementation the protocol cannot distinguish between the native script addresses (which do not need datum) and the Plutus script addresses, meaning the transaction validator cannot make decision whether an output in its pending/validating transaction requires a datum or not.

Also, keep in mind, due to the nature of UTxO model, everybody can send to any semi valid address (i.e. valid prefix and valid bytes length based on prefix but not existing address e.g, all 0s 0x80000000000....) to anything, which can mean it can be lost forever (or until there is private key generated which can derive that address).

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.