1

I am trying to mint some example tokens in offchain plutus code on tag v1.0.0-alpha1.

This is the OffChain code I am currently using:

mintFactoryToken :: Contract () MintFactorySchema Text ()
mintFactoryToken = do
  outRef <- getUnspentOutput
  pkh    <- ownFirstPaymentPubKeyHash
  o      <- fromJust <$> unspentTxOutFromRef outRef
  let
    !policy     = mintValidator outRef
    symbol     = scriptCurrencySymbol policy
    mintValue  = Value.singleton symbol contractDataTokenName 1 <> Value.singleton symbol chunkCreationTokenName 1
  Contract.logDebug outRef
  Contract.logDebug policy
  Contract.logDebug symbol
  Contract.logDebug mintValue
  let
    l          = Constraints.plutusV2MintingPolicy policy <>
                 Constraints.unspentOutputs (Map.singleton outRef o)
    constr     = Constraints.mustMintValue mintValue
  unbalanced <- Contract.mkTxConstraints @Any l constr
  Contract.logDebug @Text "Unbalanced"
  adjusted  <- Contract.adjustUnbalancedTx unbalanced
  Contract.logDebug @Text "adjusted"
  unsigned  <- Contract.balanceTx adjusted
  Contract.logDebug @Text "unsigned"
  signed    <- Contract.submitBalancedTx unsigned
  Contract.logDebug @Text "signed"
  --ledgerTx <- Contract.submitTxConstraintsWith @Void l constr
  Contract.awaitTxConfirmed $ getCardanoTxId signed
  Contract.logDebug @Text "signed"

But as soon as it reaches Contract.balanceTx adjusted I encounter the following error:

Slot 00001: *** CONTRACT STOPPED WITH ERROR: "\"WalletContractError (ValidationError (CardanoLedgerValidationError \\\"MissingScript (RdmrPtr Mint 0) (fromList [(RdmrPtr Mint 0,(Minting (PolicyID {policyID = ScriptHash \\\\\\\"2fcc3c79d2cb27a9784a7d3e69de5f1909406fcbc33567e6dd24288b\\\\\\\"}),Nothing,ScriptHash \\\\\\\"2fcc3c79d2cb27a9784a7d3e69de5f1909406fcbc33567e6dd24288b\\\\\\\"))])\\\"))\""

Do I have to do something special in order to get this to work or is this just not supported at the moment?

I've seen in the Relese Notes that some custom validation rules are used at the moment:

...

  • plutus-contract emulator has been updated to work with Babbage era types. However, the UTxO index in the emulator does not support transaction outputs with reference scripts and inline datums.
  • plutus-contract emulator uses the Babbage era validation rules from cardano-ledger. However, we continue to use our old custom validation rules which we plan to remove in the next alpha release in order to fully commit with cardano-ledger 's validation rules.

...

But I am not sure if this causes my problem or not.

Signatures of the OnChain code:

{-# INLINABLE validateMinting #-}
validateMinting :: TxOutRef -> BuiltinData -> BuiltinData -> ()
...

mintValidator :: TxOutRef -> MintingPolicy
mintValidator oRef = mkMintingPolicyScript
   ($$(Tx.compile [|| validateMinting ||]) `Tx.applyCode` Tx.liftCode oRef)

mintCurrencySymbol :: TxOutRef -> CurrencySymbol
mintCurrencySymbol = scriptCurrencySymbol . mintValidator
1
  • Can't see anything wrong with what you're doing. A lot has changed since v1.0.0-alpha1 so could you try with latest from next-node branch and see if it helps.
    – james
    Oct 3, 2022 at 12:11

1 Answer 1

1

As james noted in a comment a simple update to the head of next-node resolved the issue. now tokens are minted correctly

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.