<p>I am trying to get a UTxO of the current wallet, use it to mint a token via the <code>OneShotCurrency</code> type, but I keep getting the following Error:</p>
<p><code>(TxOutRefNotFound (TxOutRef {txOutRefId = b2f06756e65c009ced73c87919e4f8dd0e640b002a247083354f7122f82d312f, txOutRefIdx = 10}))</code></p>
<p>Here are my lookups and tx construction. Thanks for any help!</p>
<pre><code>[...]
do
    ppkh   &lt;- ownPaymentPubKeyHash
    oref   &lt;- getUnspentOutput
    utxos  &lt;- utxosAt (pubKeyHashAddress ppkh Nothing)
    let
        pol  = curPolicy $ OneShotCurrency { curRefTransactionOutput=(txOutRefId oref, txOutRefIdx oref), curAmounts=(PlutusTx.AssocMap.singleton myTokenName 1) }
        mVal = Value.singleton (scriptCurrencySymbol pol) myTokenName 1
        d    = [...]
        lookups       = Constraints.unspentOutputs utxos                            &lt;&gt;
                        Constraints.mintingPolicy pol                               &lt;&gt;
                        Constraints.typedValidatorLookups validatorInstance
        tx            = Constraints.mustSpendPubKeyOutput txOutRef                  &lt;&gt;
                        Constraints.mustPayToTheScript d (mVal &lt;&gt; Ada.adaValueOf (getAda 3000000))  &lt;&gt;
                        Constraints.mustMintValue mVal                              &lt;&gt;
                        Constraints.mustBeSignedBy ppkh
    ledgerTx &lt;- submitTxConstraints validatorInstance tx
    awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @P.String &quot;Initialized&quot;
[...]


</code></pre>

CC BY-SA 4.0
2022-08-12T19:51:24.823Z
More context is needed. Did you run this contract using PAB (`plutus-pab`) or using `plutus-contract` emulator? When you're saying "current wallet", what are you referring to?
kolam
CC BY-SA 4.0
2022-08-16T06:48:03.433Z
I ran it using the `plutus-contract` emulator.
Will
CC BY-SA 4.0
2022-08-17T09:53:55.523Z
The `txOutRef` variable is undefined. Is it actually `oref`?
kolam
<plutus><plutus-pioneer-program><utxo>
TxOutRefNotFound when using Plutus.Contract.Wallet (getUnspentOutput)
# TxOutRefNotFound when using Plutus.Contract.Wallet (getUnspentOutput)

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

I am trying to get a UTxO of the current wallet, use it to mint a token via the OneShotCurrency type, but I keep getting the following Error:
(TxOutRefNotFound (TxOutRef {txOutRefId = b2f06756e65c009ced73c87919e4f8dd0e640b002a247083354f7122f82d312f, txOutRefIdx = 10}))
Here are my lookups and tx construction. Thanks for any help!
[...]
do
    ppkh   <- ownPaymentPubKeyHash
    oref   <- getUnspentOutput
    utxos  <- utxosAt (pubKeyHashAddress ppkh Nothing)
    let
        pol  = curPolicy $ OneShotCurrency { curRefTransactionOutput=(txOutRefId oref, txOutRefIdx oref), curAmounts=(PlutusTx.AssocMap.singleton myTokenName 1) }
        mVal = Value.singleton (scriptCurrencySymbol pol) myTokenName 1
        d    = [...]
        lookups       = Constraints.unspentOutputs utxos                            <>
                        Constraints.mintingPolicy pol                               <>
                        Constraints.typedValidatorLookups validatorInstance
        tx            = Constraints.mustSpendPubKeyOutput txOutRef                  <>
                        Constraints.mustPayToTheScript d (mVal <> Ada.adaValueOf (getAda 3000000))  <>
                        Constraints.mustMintValue mVal                              <>
                        Constraints.mustBeSignedBy ppkh
    ledgerTx <- submitTxConstraints validatorInstance tx
    awaitTxConfirmed $ getCardanoTxId ledgerTx
    logInfo @P.String "Initialized"
[...]

**Tags:** plutus, plutus-pioneer-program, utxo
> **Comments:**
> **username_1**: More context is needed. Did you run this contract using PAB (`plutus-pab`) or using `plutus-contract` emulator? When you're saying "current wallet", what are you referring to?  
> **username_0**: I ran it using the `plutus-contract` emulator.  
> **username_1**: The `txOutRef` variable is undefined. Is it actually `oref`?  

---

## 0 answers

