user5565: I've been toying around with the English Auction example and I have two questions:

After an invalid bid (less than the minimum bet set for the auction) from a wallet, a second valid bid from the same wallet is also not successful. Is this intended? The trace shows the first invalid bid but not the second one, the last trace message is "Contract instance stopped with error: "bid lower than minimal bid 10000000".

Considering the following sequence of actions: auction starts, wallet 2 bids, wallet 3 outbids wallet 2, wallet 2 outbids wallet 3, auction closes. The image below shows the transaction corresponding to the second bid of wallet 2. Why do we have wallet 2 twice as an input of the transaction? I thought only wallet 2 created by slot 3 should appear as an input.




user5760: For question 1: It seems to be an issue with the way the English Auction contract is written. I believe this is a bug that someone with more knowledge of Plutus would be able to fix in the contract code.
For question 2:
When Wallet 2 was outbid, the script created a UTxO to give it back Wallet 2's original 11000000 bid.
When Wallet 2 bid again, it bid 15000000. First the unspent 11000000 was used as an input, but that's not enough to cover the 15000000 bid. So Wallet 2's other UTxO containing 88991363 is needed as an additional input.

user6113: Q1: As @Travis mentioned, that's the way the offchain code was implemented. Try as follows and you'll have a second opportunity to bid.
bid :: forall w s. BidParams -> Contract w s Text ()
bid BidParams{..} = do
  (oref, o, d@AuctionDatum{..}) <- findAuction bpCurrency bpToken
  logInfo @P.String $ printf "found auction utxo with datum %s" (P.show d)

  if (bpBid < minBid d) 
    then logError @P.String $ printf "bid lower than minimal bid %d" (minBid d)
    else do 
        pkh <- ownPaymentPubKeyHash
        let b  = Bid {bBidder = pkh, bBid = bpBid}
            d' = d {adHighestBid = Just b}
            v  = Value.singleton bpCurrency bpToken 1 <> Ada.lovelaceValueOf (minLovelace + bpBid)
            r  = Redeemer $ PlutusTx.toBuiltinData $ MkBid b

            lookups = Constraints.typedValidatorLookups typedAuctionValidator P.<>
                    Constraints.otherScript auctionValidator                P.<>
                    Constraints.unspentOutputs (Map.singleton oref o)
            tx      = case adHighestBid of
                        Nothing      -> Constraints.mustPayToTheScript d' v                            <>
                                        Constraints.mustValidateIn (to $ aDeadline adAuction)          <>
                                        Constraints.mustSpendScriptOutput oref r
                        Just Bid{..} -> Constraints.mustPayToTheScript d' v                            <>
                                        Constraints.mustPayToPubKey bBidder (Ada.lovelaceValueOf bBid) <>
                                        Constraints.mustValidateIn (to $ aDeadline adAuction)          <>
                                        Constraints.mustSpendScriptOutput oref r
        ledgerTx <- submitTxConstraintsWith lookups tx
        void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
        logInfo @P.String $ printf "made bid of %d lovelace in auction %s for token (%s, %s)"
            bpBid
            (P.show adAuction)
            (P.show bpCurrency)
            (P.show bpToken)


5565: <p>I've been toying around with the English Auction example and I have two questions:</p>
<ol>
<li><p>After an invalid bid (less than the minimum bet set for the auction) from a wallet, a second valid bid from the same wallet is also not successful. Is this intended? The trace shows the first invalid bid but not the second one, the last trace message is &quot;Contract instance stopped with error: &quot;bid lower than minimal bid 10000000&quot;.</p>
</li>
<li><p>Considering the following sequence of actions: auction starts, wallet 2 bids, wallet 3 outbids wallet 2, wallet 2 outbids wallet 3, auction closes. The image below shows the transaction corresponding to the second bid of wallet 2. Why do we have wallet 2 twice as an input of the transaction? I thought only wallet 2 created by slot 3 should appear as an input.
<a href="https://i.stack.imgur.com/CbO73.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CbO73.png" alt="enter image description here" /></a></p>
</li>
</ol>
 5760: <p><strong>For question 1</strong>: It seems to be an issue with the way the English Auction contract is written. I believe this is a bug that someone with more knowledge of Plutus would be able to fix in the contract code.</p>
<p><strong>For question 2</strong>:</p>
<p>When Wallet 2 was outbid, the script created a UTxO to give it back Wallet 2's original 11000000 bid.</p>
<p>When Wallet 2 bid again, it bid 15000000. First the unspent 11000000 was used as an input, but that's not enough to cover the 15000000 bid. So Wallet 2's other UTxO containing 88991363 is needed as an additional input.</p>
 6113: <p><strong>Q1</strong>: As @Travis mentioned, that's the way the offchain code was implemented. Try as follows and you'll have a second opportunity to bid.</p>
<pre><code>bid :: forall w s. BidParams -&gt; Contract w s Text ()
bid BidParams{..} = do
  (oref, o, d@AuctionDatum{..}) &lt;- findAuction bpCurrency bpToken
  logInfo @P.String $ printf &quot;found auction utxo with datum %s&quot; (P.show d)

  if (bpBid &lt; minBid d) 
    then logError @P.String $ printf &quot;bid lower than minimal bid %d&quot; (minBid d)
    else do 
        pkh &lt;- ownPaymentPubKeyHash
        let b  = Bid {bBidder = pkh, bBid = bpBid}
            d' = d {adHighestBid = Just b}
            v  = Value.singleton bpCurrency bpToken 1 &lt;&gt; Ada.lovelaceValueOf (minLovelace + bpBid)
            r  = Redeemer $ PlutusTx.toBuiltinData $ MkBid b

            lookups = Constraints.typedValidatorLookups typedAuctionValidator P.&lt;&gt;
                    Constraints.otherScript auctionValidator                P.&lt;&gt;
                    Constraints.unspentOutputs (Map.singleton oref o)
            tx      = case adHighestBid of
                        Nothing      -&gt; Constraints.mustPayToTheScript d' v                            &lt;&gt;
                                        Constraints.mustValidateIn (to $ aDeadline adAuction)          &lt;&gt;
                                        Constraints.mustSpendScriptOutput oref r
                        Just Bid{..} -&gt; Constraints.mustPayToTheScript d' v                            &lt;&gt;
                                        Constraints.mustPayToPubKey bBidder (Ada.lovelaceValueOf bBid) &lt;&gt;
                                        Constraints.mustValidateIn (to $ aDeadline adAuction)          &lt;&gt;
                                        Constraints.mustSpendScriptOutput oref r
        ledgerTx &lt;- submitTxConstraintsWith lookups tx
        void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
        logInfo @P.String $ printf &quot;made bid of %d lovelace in auction %s for token (%s, %s)&quot;
            bpBid
            (P.show adAuction)
            (P.show bpCurrency)
            (P.show bpToken)
</code></pre>
