I’m trying to find if a particular address submitting a transaction contains a NFT. Not necessarily the transaction itself but the address in general contains the NFT. I was looking at using TxInInfo but I believe that only contains inputs of the transaction itself. I also looked at the TxOut but that is the outputs of the transaction. Here is an example of what I was trying

{-# INLINABLE testMintingScript #-}
testMintingScript :: NFTInfo -> () -> ScriptContext -> Bool
testMintingScript nftInfo () ctx = traceIfFalse "Didn't find NFT" tokenInOutputs 
    info :: TxInfo
    info = scriptContextTxInfo ctx

    ownOutputs :: [TxOut]
    ownOutputs = txInfoOutputs info          
    tokenInOutputs :: Bool
    tokenInOutputs = any (\x -> assetClassValueOf (txOutValue x) (AssetClass (policyIdNFT nftInfo, tokenNameNFT nftInfo)) > 0) trythis   

I’ve looked through the source code and the many helper functions like findOwnInput and getContinuingOutputs but it is more of the same thing. Can someone point me in the right direction about which part of the data structure I need to look at?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.