In https://github.com/onflow/flow-nft/ can not get NFT metadata

value of type &NonFungibleToken.NFT has no member metadata. unknown member

I can’t cast NonFungibleToken.NFT as ExampleToken.NFT
mismatched types. expected &ExampleNFT.NFT, got &NonFungibleToken.NFT

1 Like

This is because the reference that is returned is the type &NonFungibleToken.NFT. References cannot be cast to the concrete type unless they are authorized references. If you want to get a full reference to your NFT so you can get the metadata field from it, you need to have a special function to return the reference, kind of like in the TopShot contract: https://github.com/dapperlabs/nba-smart-contracts/blob/master/contracts/TopShot.cdc#L652-L669