<p><code>ExtraneousScriptWitnessesUTXOW</code> means the script witness is being included in the txbody when it doesn't need to be because the witness requirement is already satisfied by a reference script.</p>
<p>Either include the script in the txbody OR reference the UTxO where the script has been stored when building a transaction. You are only allowed to do one or the other.</p>

CC BY-SA 4.0
2023-03-19T11:32:48.667Z
Thanks for your answer James, but I still don't fully understand... Does this mean that an error was made while creating the transaction `0f7262...c3a676` ? And now there is no way to collect this UTXO from the gift address?
dmitry_stas
CC BY-SA 4.0
2023-03-20T09:13:18.027Z
No. It means the transaction you are currently building is including both. e.g.. with the cli you are using both `--tx-in-script-file` and `--spending-tx-in-reference`
james
CC BY-SA 4.0
2023-03-20T09:25:13.290Z
That output you are spending has both the reference script and the inline datum. So because you need to reference the input for its datum you must also use the reference script and not provide the script file.
james
CC BY-SA 4.0
2023-03-23T10:52:32.413Z
Thanks for your patience James, the solution finally dawned on me :) My mistake was that when I tried to create the UTXO like `0f7262...c3a676`, I specified a vesting.plutus as tx-out-reference-script-file, just for testing. But it 'works' (the error ExtraneousScriptWitnessesUTXOW occurs) only with `--tx-out-reference-script-file "$assets/gift.plutus"`. Probably, in the case when the scripts do not match each other, the offchain validation does not start at all
dmitry_stas
CC BY-SA 4.0
2023-03-23T10:56:27.430Z
Unfortunately I can't mark your answer as correct, because It requires 15 reputation at least, but you've helped me a lot. Thank you very much!
dmitry_stas
CC BY-SA 4.0
2023-03-17T09:19:34.970Z
2023-03-17T09:19:34.970Z
james
<p>I'm following Plutus Pioneers Program, 4th Cohort.</p>
<p>In the 2nd week we learned the smart contract Gift.hs</p>
<pre><code>-- This validator always succeeds
mkGiftValidator :: BuiltinData -&gt; BuiltinData -&gt; BuiltinData -&gt; ()
mkGiftValidator _ _ _ = ()
</code></pre>
<p>and used make-gift.sh and collect-gift.sh scripts for sending/receiving ada to/from Gift.addr script address <code>addr_test1wqag3rt979nep9g2wtdwu8mr4gz6m4kjdpp5zp705km8wys6t2kla</code></p>
<p>This address has some UTXOs like this one</p>
<pre><code>                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------

0f7262dba9374e8819a2170516a86b70e3857001f9c0dbe82ebaafcac1c3a676     0        1000000000 lovelace + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [])
</code></pre>
<p>which looks correct from the smartcontract's point of view (has TxOutDatumInline, etc), but when I try to send the tx and collect this utxo I get the error</p>
<pre><code>Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (ExtraneousScriptWitnessesUTXOW (fromList [ScriptHash &quot;3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712&quot;]))))])
</code></pre>
<p>Could someone explain me please why this is happening? Shouldn't the smart contract validator always succeeds?</p>

CC BY-SA 4.0
2023-04-23T22:03:37.430Z
I'm using only --tx-in-script-file and having the same error. I noticed that if you include the script of the same smart contract, I'm obliged to reference the script rather than using --tx-in-script-file. I want to be able to use --tx-in-script-file even if the UTXO includes a reference to the same script. Any solution for that?
user9410
<plutus-pioneer-program>
Can't collect utxo from the gift script address
# Can't collect utxo from the gift script address

(Asked by: username_0 on 2023-03-16)

I'm following Plutus Pioneers Program, 4th Cohort.
In the 2nd week we learned the smart contract Gift.hs
-- This validator always succeeds
mkGiftValidator :: BuiltinData -> BuiltinData -> BuiltinData -> ()
mkGiftValidator _ _ _ = ()

and used make-gift.sh and collect-gift.sh scripts for sending/receiving ada to/from Gift.addr script address addr_test1wqag3rt979nep9g2wtdwu8mr4gz6m4kjdpp5zp705km8wys6t2kla
This address has some UTXOs like this one
                           TxHash                                 TxIx        Amount
--------------------------------------------------------------------------------------

0f7262dba9374e8819a2170516a86b70e3857001f9c0dbe82ebaafcac1c3a676     0        1000000000 lovelace + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [])

which looks correct from the smartcontract's point of view (has TxOutDatumInline, etc), but when I try to send the tx and collect this utxo I get the error
Command failed: transaction submit  Error: Error while submitting tx: ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (FromAlonzoUtxowFail (WrappedShelleyEraFailure (ExtraneousScriptWitnessesUTXOW (fromList [ScriptHash "3a888d65f16790950a72daee1f63aa05add6d268434107cfa5b67712"]))))])

Could someone explain me please why this is happening? Shouldn't the smart contract validator always succeeds?

**Tags:** plutus-pioneer-program
> **Comments:**
> **username_1**: I'm using only --tx-in-script-file and having the same error. I noticed that if you include the script of the same smart contract, I'm obliged to reference the script rather than using --tx-in-script-file. I want to be able to use --tx-in-script-file even if the UTXO includes a reference to the same script. Any solution for that?  

---

## 1 answers

### Answer by username_2 on 2023-03-17. Score: 2 | Accepted answer

`ExtraneousScriptWitnessesUTXOW` means the script witness is being included in the txbody when it doesn't need to be because the witness requirement is already satisfied by a reference script.

Either include the script in the txbody OR reference the UTxO where the script has been stored when building a transaction. You are only allowed to do one or the other.

> **Comments:**
> **username_0**: Thanks for your answer James, but I still don't fully understand... Does this mean that an error was made while creating the transaction `0f7262...c3a676` ? And now there is no way to collect this UTXO from the gift address?  
> **username_2**: No. It means the transaction you are currently building is including both. e.g.. with the cli you are using both `--tx-in-script-file` and `--spending-tx-in-reference`  
> **username_2**: That output you are spending has both the reference script and the inline datum. So because you need to reference the input for its datum you must also use the reference script and not provide the script file.  
> **username_0**: Thanks for your patience James, the solution finally dawned on me :) My mistake was that when I tried to create the UTXO like `0f7262...c3a676`, I specified a vesting.plutus as tx-out-reference-script-file, just for testing. But it 'works' (the error ExtraneousScriptWitnessesUTXOW occurs) only with `--tx-out-reference-script-file "$assets/gift.plutus"`. Probably, in the case when the scripts do not match each other, the offchain validation does not start at all  
> **username_0**: Unfortunately I can't mark your answer as correct, because It requires 15 reputation at least, but you've helped me a lot. Thank you very much!  

---

