user5801: 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


user5801: 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

5801: <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>
 5801: <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>
