1

I am following through the third cohort PPP. With a week of course break, I wish to consolidate my understanding through practice. One exercise is to go through the deployment process of an NFT:

  1. Construct the plutus script (e.g. homework of week 5)
  2. Test it on the plutus playground / run the EmulatorTrace
  3. Write the plutus file through a script like week 3's Deploy.hs.
  4. Build & Submit the transaction on testnet

Following through Lars's lecture, there is no problem for step 1-2. However, I got stuck at step 3. The two relevant lines from week 3's Deploy.hs should be:

writeValidator :: FilePath -> Ledger.Validator -> IO (Either (FileError ()) ())
writeValidator file = writeFileTextEnvelope @(PlutusScript PlutusScriptV1) file Nothing . PlutusScriptSerialised . SBS.toShort . LBS.toStrict . serialise . Ledger.unValidatorScript

writeVestingValidator :: IO (Either (FileError ()) ())
writeVestingValidator = writeValidator "/Users/whatever/Desktop/Plutus-Pioneer-Program/testnet/vesting.plutus" $ validator $ VestingParam
    { beneficiary = Ledger.PaymentPubKeyHash "0d26b900ffa6a3234166ed76467e80fbd8e1f6bad938f75cb884ef6b"
    , deadline    = 1645113135000
    }

The logic should be calling the validator function from the Parameterized.hs at writeVestingValidator, then put it in writeValidator to output the plutus file. However, it cannot directly copy and paste for week 5's NFT haskell scripts as the Ledger.unValidatorScript takes in a Validator as parameter while there is no Validator type inside the NFT policy script.

I have found unMintingPolicyScript in the haddock to replace unValidatorScript, but to no avail. My final attempt is like below:

writeValidator :: FilePath -> Ledger.Validator -> IO (Either (FileError ()) ())
writeValidator file = writeFileTextEnvelope @(PlutusScript PlutusScriptV1) file Nothing . PlutusScriptSerialised . SBS.toShort . LBS.toStrict . serialise . Ledger.unMintingPolicyScript

writeNFTValidator :: IO (Either (FileError ()) ())
writeNFTValidator = writeValidator "/Users/whatever/Desktop/Plutus-Pioneer-Program/testnet/nft/mint-TokenWithMeta.plutus" $ (policy (Ledger.TxOutRef "f79a3a51ecc200b6ccfdb5d083652787fc3c389a30d9d5b75bcd883428b9c9d5#0") (TokenName "TestNFT"))

Sorry its kind of a mess, But somehow I get stuck here.

I have tried to look at different guides, the first is from official Cardano documentation https://developers.cardano.org/docs/native-tokens/minting-nfts/. It doesn't solve my doubt as it seems not using plutus script to mint the NFT.

Another guide (Is there a good tutorial to mint Cardano NFT using plutus script?) has a walk through on deploying NFT plutus script, however, it uses a cabal command link cabal run create-nft-script -- PlutusScriptNFT 6c1160302bff7c84b347e6c9c1cf78cbafc8821efc730f6271589fcd848635f7#0 to serve the purpose. However, I want to perform the write script through haskell script so it can be more repeatable when I start building more complex validator or policy.

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Commented Feb 21, 2022 at 2:46

0

Your Answer

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

Browse other questions tagged or ask your own question.