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.
True
.PubKeyHash
by not submitting them in one transaction.