[issue] Error down casting NFT from NonFungibleToken

Hi guys, I’ve created a NFT contract using this ExampleNFT.cdc as a reference. https://github.com/onflow/flow-nft/blob/master/contracts/ExampleNFT.cdc
my contract: https://testnet.flowscan.org/contract/A.10389afd0d4ac851.InfiniteNFTV2

When I use the borrow method (borrowExampleNFT in ExampleNFT contract)
pub fun borrow(id: UInt64): &NFT? {
if self.ownedNFTs[id] != nil {
let ref = (&self.ownedNFTs[id] as auth &NonFungibleToken.NFT?)
return ref as! &NFT
return nil
I receive the following error message
error: unexpectedly found non-&InfiniteNFTV2.NFT while force-casting value
→ 10389afd0d4ac851.InfiniteNFTV2:102:23
102 | return ref as! &NFT
You guys have any idea about this meesage? Thanks in advance.

1 Like

Solved! just replacing the references from &NFT to &InfiniteNFTV2.NFT

pub fun borrow(id: UInt64): &InfiniteNFTV2.NFT? {
        let ref = (&self.ownedNFTs[id] as auth &NonFungibleToken.NFT?)!
        return ref as! &InfiniteNFTV2.NFT
1 Like