<p>I am not sure I understand the question...</p>
<p>First of all, scripts do not &quot;generate transactions&quot;, but <em>validate</em> transactions. Transactions are <em>generated</em> by wallets (and off-chain wallet code).</p>
<p>Now, what <em>is</em> the output of a transaction? In the EUTxO-model, it is given by three &quot;things&quot;:</p>
<ul>
<li>an <em>address</em></li>
<li>a *value' and</li>
<li>a <em>datum</em>.</li>
</ul>
<p>The <code>txOutAddress</code> function simply extracts the first component of this triple.</p>
<p>So in my example, I am looking for inputs who try to unlock outputs that &quot;sit&quot; at the oracle address. Since the oracle address is a script address, the corresponding oracle validator script will be executed to determine whether the transaction I am looking at is allowed to consume this input.</p>

CC BY-SA 4.0
2021-06-06T20:53:28.460Z
2021-06-06T20:53:28.460Z
Lars Brünjes
<p>In Week 6 of PP Lars finds an oracle input with the following code:</p>
<pre><code>oracleInput :: TxOut
    oracleInput =
      let
        ins = [ o
              | i &lt;- txInfoInputs info
              , let o = txInInfoResolved i
              -- addr = oracle's address
              , txOutAddress o == addr
              ]
      in
        case ins of
            [o] -&gt; o
            _   -&gt; traceError &quot;expected exactly one oracle input&quot;
</code></pre>
<p>Does it imply that if a script creates a transaction then transaction outputs will reference the script address through <code>txOutAddress</code> field?</p>
<p>Thank you :)</p>

CC BY-SA 4.0
2021-06-04T08:21:41.793Z
Here is the code in question: https://github.com/input-output-hk/plutus-pioneer-program/blob/36084859defd87c6f13eb166ec64f0d6c6db1242/code/week06/src/Week06/Oracle/Swap.hs#L57
Antony Woods
<plutus>
How is a transaction output's address generated?
# How is a transaction output's address generated?

(Asked by: username_0 on 2021-06-03)

In Week 6 of PP Lars finds an oracle input with the following code:
oracleInput :: TxOut
    oracleInput =
      let
        ins = [ o
              | i <- txInfoInputs info
              , let o = txInInfoResolved i
              -- addr = oracle's address
              , txOutAddress o == addr
              ]
      in
        case ins of
            [o] -> o
            _   -> traceError "expected exactly one oracle input"

Does it imply that if a script creates a transaction then transaction outputs will reference the script address through txOutAddress field?
Thank you :)

**Tags:** plutus
> **Comments:**
> **username_1**: Here is the code in question: https://github.com/input-output-hk/plutus-pioneer-program/blob/36084859defd87c6f13eb166ec64f0d6c6db1242/code/week06/src/Week06/Oracle/Swap.hs#L57  

---

## 1 answers

### Answer by username_2 on 2021-06-06. Score: 2 | Accepted answer

I am not sure I understand the question...

First of all, scripts do not "generate transactions", but *validate* transactions. Transactions are *generated* by wallets (and off-chain wallet code).

Now, what *is* the output of a transaction? In the EUTxO-model, it is given by three "things":

* an *address*
* a \*value' and
* a *datum*.

The `txOutAddress` function simply extracts the first component of this triple.

So in my example, I am looking for inputs who try to unlock outputs that "sit" at the oracle address. Since the oracle address is a script address, the corresponding oracle validator script will be executed to determine whether the transaction I am looking at is allowed to consume this input.


---

