<p><code>expected: Value (Map [(,Map [(\\\&quot;\\\&quot;,3242)])])\&quot;)&quot;</code></p>
<p>Try adding a few zeros to the starting balances. It's saying it doesn't have enough to pay the fees.</p>
<p>I'm surprised that the first transaction worked, but without seeing all of your code it's hard to diagnose why.</p>

CC BY-SA 4.0
2021-10-25T17:26:13.100Z
Yeah that was exactly it, thank you!!
glneto
CC BY-SA 4.0
2021-10-25T17:23:13.547Z
2021-10-25T17:23:13.547Z
Mitchell Turner
<p>Transaction should be done by someone, in this case by the Buyer. In order to do that, buyer should pay the fees of the transaction.</p>
<p>Actually, this error is explaining that buyer has less lovelace than the required to pay the fees.</p>
<pre><code>&quot;WalletError (InsufficientFunds \&quot;Total: Value (Map [(,Map [(\\\&quot;\\\&quot;,100)])]) expected: Value (Map [(,Map [(\\\&quot;\\\&quot;,3242)])])\&quot;)&quot; ]
</code></pre>
<p>Buyer has 100 lovelace and it's required to pay 3242.</p>
<p>Function <code>collectFromScript</code> has nothing to do with it.</p>

CC BY-SA 4.0
2021-10-25T17:25:11.740Z
2021-10-25T17:25:11.740Z
georgeos
<p>I was following the example from the <a href="https://playground.plutus.iohkdev.io/doc/plutus/tutorials/basic-apps.html" rel="nofollow noreferrer">basic split app</a> and changing it a bit to try to make a simple sell/buy NFT transaction.</p>
<p>For now I'm just trying to transfer the NFT from one wallet to another.</p>
<p>My idea is basically that a user has to call the 'Offer' endpoint to send the NFT to the script and then the other wallet calls the 'Buy' endpoint to get the NFT.</p>
<pre><code>doOffer :: OfferArgs -&gt; Contract () MarketplaceSchema T.Text ()
doOffer offerData@OfferArgs{..} = do
    pkh &lt;- pubKeyHash &lt;$&gt; Plutus.Contract.ownPubKey
    let offerData = OfferData
                { seller         = pkh
                , price          = aPrice
                , nftCurrencySymbol = aCurrencySymbol
                , nftTokenName      = aTokenName
                }
    logInfo @Haskell.String $ printf &quot;creating offer %s&quot; (Haskell.show offerData)
    let tx = Constraints.mustPayToTheScript offerData (Value.singleton aCurrencySymbol aTokenName 1)
    void $ submitTxConstraints offerValidator tx

doBuy :: OfferArgs -&gt; Contract () MarketplaceSchema T.Text ()
doBuy offer@OfferArgs{..} = do
    logInfo @Haskell.String $ printf &quot;buying %s&quot; (Haskell.show offer)
    pkh &lt;- pubKeyHash &lt;$&gt; Plutus.Contract.ownPubKey
    let contractAddress = Scripts.validatorAddress offerValidator
    utxos &lt;- utxosAt contractAddress
    let tx =
            collectFromScript utxos Buy
            &lt;&gt; Constraints.mustPayToPubKey pkh (Value.singleton aCurrencySymbol aTokenName 1) -- Send the NFT to buyer
    void $ submitTxConstraintsSpending offerValidator utxos tx
</code></pre>
<p>The offer part seems to work well, and the NFT shows up at the script output. However when I try to send it to the buyer in <code>mustPayToPubKey</code> I get an error:</p>
<pre><code>Contract instance stopped with error: &quot;WalletError (InsufficientFunds \&quot;Total: Value (Map [(,Map [(\\\&quot;\\\&quot;,100)])]) expected: Value (Map [(,Map [(\\\&quot;\\\&quot;,3242)])])\&quot;)&quot; ]
</code></pre>
<p>I don't know but it looks like it's trying to pay the token using the Buyer's wallet, but I thought the collectFromScript part was supposed to use script utxo?</p>
<p>Here is how it looks in the simulator when the error occurs:
<a href="https://i.sstatic.net/KMNtg.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/KMNtg.png" alt="Simulator" /></a></p>
<p>I believe the rest of the code is not necessary as I'm not doing any kind of complex validation yet, I'm just trying to make a simple transfer but if you need the validator piece let me know :)</p>

<plutus><plutus-pioneer-program><haskell>
Insufficient funds when trying to use script unspent output
# Insufficient funds when trying to use script unspent output

(Asked by: username_0 on 2021-10-25)

I was following the example from the basic split app and changing it a bit to try to make a simple sell/buy NFT transaction.
For now I'm just trying to transfer the NFT from one wallet to another.
My idea is basically that a user has to call the 'Offer' endpoint to send the NFT to the script and then the other wallet calls the 'Buy' endpoint to get the NFT.
doOffer :: OfferArgs -> Contract () MarketplaceSchema T.Text ()
doOffer offerData@OfferArgs{..} = do
    pkh <- pubKeyHash <$> Plutus.Contract.ownPubKey
    let offerData = OfferData
                { seller         = pkh
                , price          = aPrice
                , nftCurrencySymbol = aCurrencySymbol
                , nftTokenName      = aTokenName
                }
    logInfo @Haskell.String $ printf "creating offer %s" (Haskell.show offerData)
    let tx = Constraints.mustPayToTheScript offerData (Value.singleton aCurrencySymbol aTokenName 1)
    void $ submitTxConstraints offerValidator tx

doBuy :: OfferArgs -> Contract () MarketplaceSchema T.Text ()
doBuy offer@OfferArgs{..} = do
    logInfo @Haskell.String $ printf "buying %s" (Haskell.show offer)
    pkh <- pubKeyHash <$> Plutus.Contract.ownPubKey
    let contractAddress = Scripts.validatorAddress offerValidator
    utxos <- utxosAt contractAddress
    let tx =
            collectFromScript utxos Buy
            <> Constraints.mustPayToPubKey pkh (Value.singleton aCurrencySymbol aTokenName 1) -- Send the NFT to buyer
    void $ submitTxConstraintsSpending offerValidator utxos tx

The offer part seems to work well, and the NFT shows up at the script output. However when I try to send it to the buyer in mustPayToPubKey I get an error:
Contract instance stopped with error: "WalletError (InsufficientFunds \"Total: Value (Map [(,Map [(\\\"\\\",100)])]) expected: Value (Map [(,Map [(\\\"\\\",3242)])])\")" ]

I don't know but it looks like it's trying to pay the token using the Buyer's wallet, but I thought the collectFromScript part was supposed to use script utxo?
Here is how it looks in the simulator when the error occurs:

I believe the rest of the code is not necessary as I'm not doing any kind of complex validation yet, I'm just trying to make a simple transfer but if you need the validator piece let me know :)

**Tags:** plutus, plutus-pioneer-program, haskell

---

## 2 answers

### Answer by username_1 on 2021-10-25. Score: 3 | Accepted answer

`expected: Value (Map [(,Map [(\\\"\\\",3242)])])\")"`

Try adding a few zeros to the starting balances. It's saying it doesn't have enough to pay the fees.

I'm surprised that the first transaction worked, but without seeing all of your code it's hard to diagnose why.

> **Comments:**
> **username_0**: Yeah that was exactly it, thank you!!  

---

### Answer by username_2 on 2021-10-25. Score: 2

Transaction should be done by someone, in this case by the Buyer. In order to do that, buyer should pay the fees of the transaction.
Actually, this error is explaining that buyer has less lovelace than the required to pay the fees.
"WalletError (InsufficientFunds \"Total: Value (Map [(,Map [(\\\"\\\",100)])]) expected: Value (Map [(,Map [(\\\"\\\",3242)])])\")" ]

Buyer has 100 lovelace and it's required to pay 3242.
Function collectFromScript has nothing to do with it.


---

