<p>The issue was caused by the lookups. The combination of Constraints that resolved the issue is <code>let lookups = Constraints.unspentOutputs utxos &lt;&gt; Constraints.typedValidatorLookups typedPayToScriptValidator &lt;&gt; Constraints.otherScript (Scripts.validatorScript typedPayToScriptValidator)</code> I'm not sure exactly what these lookup constraints do and why they are necessary, but they fixed the ConstraintResolutionError</p>

CC BY-SA 4.0
2022-07-07T14:48:22.973Z
*smacks self on forehead* - I've been stuck on the exact same error. I couldn't figure out why it couldn't find a TxOutRef that I had just found a few lines earlier using utxosTxOutTxAt, but it's the lookups! 
thanks!
marcel_g
CC BY-SA 4.0
2022-05-10T01:58:18.627Z
2022-05-10T01:58:18.627Z
Kyle Murphy
<p>I'm getting the following error during the ledgerTx line of code
<code>&quot;ConstraintResolutionError (TxOutRefNotFound (TxOutRef {txOutRefId = 70d473b55eaac244c821a001fe153813249c22395cb55631f34eb149937d340a, txOutRefIdx = 1}))&quot;</code></p>
<pre><code>utxos &lt;- utxosAt $ scriptAddress payValidator
let orefs = fst &lt;$&gt; Map.toList utxos
     change = _ciTxOutValue (snd (L.head (Map.toList utxos))) - (Ada.lovelaceValueOf bet)
     lookups = Constraints.typedValidatorLookups typedPayToScriptValidator
     tx = Constraints.mustSpendScriptOutput (last orefs) unitRedeemer &lt;&gt; Constraints.mustPayToTheScript bet change
ledgerTx &lt;- submitTxConstraintsWith lookups tx
void $ awaitTxConfirmed $ getCardanoTxId ledgerTx
</code></pre>

<plutus>
ConstraintResolutionError
# ConstraintResolutionError

(Asked by: username_0 on 2022-05-06)

I'm getting the following error during the ledgerTx line of code
"ConstraintResolutionError (TxOutRefNotFound (TxOutRef {txOutRefId = 70d473b55eaac244c821a001fe153813249c22395cb55631f34eb149937d340a, txOutRefIdx = 1}))"
utxos <- utxosAt $ scriptAddress payValidator
let orefs = fst <$> Map.toList utxos
     change = _ciTxOutValue (snd (L.head (Map.toList utxos))) - (Ada.lovelaceValueOf bet)
     lookups = Constraints.typedValidatorLookups typedPayToScriptValidator
     tx = Constraints.mustSpendScriptOutput (last orefs) unitRedeemer <> Constraints.mustPayToTheScript bet change
ledgerTx <- submitTxConstraintsWith lookups tx
void $ awaitTxConfirmed $ getCardanoTxId ledgerTx

**Tags:** plutus

---

## 1 answers

### Answer by username_0 on 2022-05-10. Score: 1 | Accepted answer

The issue was caused by the lookups. The combination of Constraints that resolved the issue is `let lookups = Constraints.unspentOutputs utxos <> Constraints.typedValidatorLookups typedPayToScriptValidator <> Constraints.otherScript (Scripts.validatorScript typedPayToScriptValidator)` I'm not sure exactly what these lookup constraints do and why they are necessary, but they fixed the ConstraintResolutionError

> **Comments:**
> **username_1**: *smacks self on forehead* - I've been stuck on the exact same error. I couldn't figure out why it couldn't find a TxOutRef that I had just found a few lines earlier using utxosTxOutTxAt, but it's the lookups!  thanks!  

---

