<p>I had a similar question:
&quot;How do you handle 2 continuing outputs?&quot;
Couldn't find any answers or documentation
anywhere!</p>
<p>After lots of experimenting, I came up with
the following code. (it handles 2 continuing outputs).
Probably not the most efficient, but it
works:</p>
<pre><code>ownOutputa = (getContinuingOutputs ctx) !! 0
ownOutputb = (getContinuingOutputs ctx) !! 1

myDatum :: TxOut -&gt; (DatumHash -&gt; Maybe Datum) -&gt; Maybe MyDatum
myDatum o f = do
    dh      &lt;- txOutDatum o
    Datum d &lt;- f dh
    PlutusTx.fromBuiltinData d

outputDatuma :: MyDatum
outputDatuma = case myDatum ownOutputa (`findDatum` info) of
    Nothing -&gt; traceError &quot;output datum a not found&quot;
    Just d  -&gt; d

outputDatumb :: MyDatum
outputDatumb = case myDatum ownOutputb (`findDatum` info) of
    Nothing -&gt; traceError &quot;output datum b not found&quot;
    Just d  -&gt; d
</code></pre>

CC BY-SA 4.0
2022-02-27T21:02:23.807Z
2022-02-27T21:02:23.807Z
Gary Alexander
<p>In the auction code of the Plutus pioneer program during week 1, the code approves a bid by comparing the datum with previous ones in the Plutus on-chain code. How could you repurpose this so that you could store multiple utxos of different datums tokens on the smart contract then verify transactions for only the tokens that match the needed datum?</p>
<p>This is the code i'm refrencing</p>
<pre><code>ownOutput   :: TxOut
        outputDatum :: Integer
        (ownOutput, outputDatum) = case getContinuingOutputs ctx of
            [o] -&gt; case txOutDatumHash o of
                Nothing   -&gt; traceError &quot;wrong output type&quot;
                Just h -&gt; case findDatum h info of
                    Nothing        -&gt; traceError &quot;datum not found&quot;
                    Just (Datum d) -&gt;  case PlutusTx.fromBuiltinData d of
                        Just iDatum' -&gt; (o, iDatum')
                        Nothing  -&gt; traceError &quot;error decoding data&quot;
            _   -&gt; traceError &quot;expected exactly one continuing output&quot;   
</code></pre>

CC BY-SA 4.0
2022-01-31T01:05:37.533Z
This is not a free code foundry.  If you attempt a solution and have problems, then the answers may be found here or you could ask about the _specific_ problem you are having.
gRebel
CC BY-SA 4.0
2022-01-31T01:06:11.080Z
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
Community
<plutus><plutus-pioneer-program>
How to separate continuing outputs to compare datums
# How to separate continuing outputs to compare datums

(Asked by: username_0 on 2022-01-28)

In the auction code of the Plutus pioneer program during week 1, the code approves a bid by comparing the datum with previous ones in the Plutus on-chain code. How could you repurpose this so that you could store multiple utxos of different datums tokens on the smart contract then verify transactions for only the tokens that match the needed datum?
This is the code i'm refrencing
ownOutput   :: TxOut
        outputDatum :: Integer
        (ownOutput, outputDatum) = case getContinuingOutputs ctx of
            [o] -> case txOutDatumHash o of
                Nothing   -> traceError "wrong output type"
                Just h -> case findDatum h info of
                    Nothing        -> traceError "datum not found"
                    Just (Datum d) ->  case PlutusTx.fromBuiltinData d of
                        Just iDatum' -> (o, iDatum')
                        Nothing  -> traceError "error decoding data"
            _   -> traceError "expected exactly one continuing output"

**Tags:** plutus, plutus-pioneer-program
> **Comments:**
> **username_1**: This is not a free code foundry.  If you attempt a solution and have problems, then the answers may be found here or you could ask about the _specific_ problem you are having.  
> **username_2**: Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.  

---

## 1 answers

### Answer by username_3 on 2022-02-27. Score: 0

I had a similar question:
"How do you handle 2 continuing outputs?"
Couldn't find any answers or documentation
anywhere!
After lots of experimenting, I came up with
the following code. (it handles 2 continuing outputs).
Probably not the most efficient, but it
works:
ownOutputa = (getContinuingOutputs ctx) !! 0
ownOutputb = (getContinuingOutputs ctx) !! 1

myDatum :: TxOut -> (DatumHash -> Maybe Datum) -> Maybe MyDatum
myDatum o f = do
    dh      <- txOutDatum o
    Datum d <- f dh
    PlutusTx.fromBuiltinData d

outputDatuma :: MyDatum
outputDatuma = case myDatum ownOutputa (`findDatum` info) of
    Nothing -> traceError "output datum a not found"
    Just d  -> d

outputDatumb :: MyDatum
outputDatumb = case myDatum ownOutputb (`findDatum` info) of
    Nothing -> traceError "output datum b not found"
    Just d  -> d


---

