I am trying to build a transaction that mints a number of tokens and distributes them to different wallets. Like here:

vote :: forall w s. Poll -> Contract w s Text ()
vote poll = do
  let lookups = mintingPolicy (receiptPolicyI $ ReceiptPolicy "")
                <> mintingPolicy (votePolicyI $ VotePolicy "")
  let tx = (mustMintValue $ assetClassValue voteAC -10)
            <> (mustMintValue $ assetClassValue receiptAC 10)
            <> (mustPayToPubKey wallet1 (assetClassValue receiptAC 5))
            <> (mustPayToPubKey wallet2 (assetClassValue receiptAC 5))
  ledgerTx <- submitTxConstraintsWith @Polling lookups tx

In this example 10 votes are burned and 10 receipts are minted. The 10 receipts shall be paid to 2 wallets.

Now when I test this, an error is thrown. It complains that there are insufficient funds in the wallet that submits the transaction. It says that 10 assets of type receiptAC are missing.

Now, of course these assets are missing in the wallet because I want to mint them in the same transaction that also distributes them.

How can I achieve this ? Maybe I am using mustPayToPubKey wrong and should indicate the distribution differently.

  • 2
    Are you testing with the emulator trace? Is the error from the emulator? I'd recommend constraining everything so the only thing you're trying to do is mint to two wallets: remove the vote stuff and set your minting policies to just True. Commented Oct 13, 2021 at 23:04
  • 1
    In fact, can you include your entire error message in your question? Commented Oct 13, 2021 at 23:05
  • 1
    Hi Mitchell, thank you for the feedback. I'm testing in the emulator trace and printing out additional logs to trace. I'll simplify the code and test again. Your comment gives me confidence that it is an error on my part. I was already afraid that this behaviour was expected. That would have been very bad for me : ).
    – Jey
    Commented Oct 14, 2021 at 7:34
  • I'd suggest you introduce delay between the transaction doing the minting and the transaction that pays into the different PubKeyHash by not submitting them in one transaction.
    – Aoaddeola
    Commented Oct 14, 2021 at 22:26

1 Answer 1


Here comes the answer: The example code above is a simplified extract of the real code I was running. In the latter, I wasn't setting the value to be minted to the constant 10 but using a function to derive it from a data structure. And here was the problem. It evaluated to 0 because of a small mistake. So I was not minting any receipt-tokens. I had not seen it because another, very similar use case was running without problems.

So the good message is, there is absolutely no issue in Plutus. Minting and distributing tokens to arbitrary output-utxos in a single transaction is absolutely feasible.

Thanks, Mitchell, for the rapid support.

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.