2

When the Alonzo era started on mainnet, Lars deployed a smart contract example, in which he minted a lobster NFT as part of a lobster naming challenge.

In the policy script used to mint the lobster NFT - link to policy/validator code, the argument inputs for the tokenName and the UTxO are baked into the compiled Plutus script, since it's a parameterized typed policy/validator. By "baked in" I mean the validator code compiled to plutus already includes the token name and UTxO, so these args do not need to passed as datum when executing the transaction.

However, in the deploy script to mint the lobster NFT - link to deploy script, there is an parameter tx-out-datum-hash set in the cardano-cli transaction build. What datum does this hashed value represent and how is the hash computed? In Lars' example code, the value is hard-coded and no explanation is given for what it represents.

1 Answer 1

3

That value is the hash value of an empty list. You can calculate it in the repl as follows:

import Ledger qualified
import PlutusTx qualified

emptyListDatum = Ledger.Datum $ PlutusTx.toBuiltinData ([] :: [()])
emptyListDatumHash = Ledger.datumHash emptyListDatum -- 45b0cfc220ceec5b7c1c62c4d4193d38e4eba48e8815729ce75f9c0ab0e4c1c0

Note that the datum selected by Lars is completely arbitrary because it's not used in the validator script.

enter image description here

2
  • That's brilliant. Thanks @kindofdev. Feb 9, 2022 at 15:10
  • You’re more than welcome. Glad to help!
    – kindofdev
    Feb 9, 2022 at 15:14

Your Answer

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

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