github.com/DapperCollectives/CAST/backend@v0.0.0-20230921221157-1350c8be7c96/main/cadence/scripts/custom/get_topshot_metadata.cdc (about)

     1  import TopShot from 0xf8d6e0586b0a20c7
     2  import MetadataViews from 0xf8d6e0586b0a20c7
     3  
     4  
     5  pub fun main(address: Address, id: UInt64): TopShot.TopShotMomentMetadataView {
     6      let account = getAccount(address)
     7  
     8      let collectionRef = account.getCapability(/public/MomentCollection)
     9                              .borrow<&{TopShot.MomentCollectionPublic}>()!
    10  
    11      let nft = collectionRef.borrowMoment(id: id)!
    12      
    13      // Get the Top Shot specific metadata for this NFT
    14      let view = nft.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
    15  
    16      let metadata = view as! TopShot.TopShotMomentMetadataView
    17      
    18      return metadata
    19  }