Hey folks, I’m scratching my head over here. I’m trying to grab the metadata for the Genesis collection from the DriverzNFT contract, but I’m hitting a wall. I’ve got a script that should do the trick, but something’s not right.
Here’s what I’m working with:
import FancyRide from 0xb123456789abcdef
import TokenStandard from 0x9876543210fedcba
import DataViews from 0x9876543210fedcba
pub fun main(wallet: Address): [&FancyRide.NFT] {
let nftSet = getAccount(wallet).getCapability(FancyRide.CollectionPublicPath)
.borrow<&FancyRide.Collection{TokenStandard.CollectionPublic, TokenStandard.Receiver, DataViews.ResolverCollection}>(FancyRide.CollectionPublic)
?? panic('Collection not found')
let output: [&FancyRide.NFT] = []
let tokenIDs = nftSet.getIDs()
for id in tokenIDs {
output.append(nftSet.borrowFancyRide(id: id))
}
return output
}
I’ve double-checked the transaction to see where the NFTs are stored and linked when they’re sent over. I’ve also looked at the contract to see how the collection interface is set up. But I’m still stumped on why I can’t pull this data.
The weird thing is, I ran another script to check if the NFT exists in my account, and it came back positive. So why won’t this script share the data, especially when I’m using the same path in the getCapability object?
Any ideas what I might be missing here? I’m all ears for suggestions!
hey there, have u tried checking if the Collection is implemented correctly in the contract? sometimes the issue is with how the interfaces are set up. also, make sure ur using the right borrowNFT method, not borrowFancyRide. and double check ur account capabilities - they gotta be set up right for this to work. good luck!
I’ve encountered similar issues when working with NFT metadata retrieval. One thing that stands out in your script is the use of borrowFancyRide. This method isn’t standard and might not exist in the FancyRide.Collection interface.
Try replacing it with borrowNFT(id: id), which is more commonly used. Also, ensure you’re casting the borrowed NFT to the correct type:
output.append(nftSet.borrowNFT(id: id) as! &FancyRide.NFT)
If that doesn’t work, double-check the contract’s public interfaces. Sometimes, the metadata access functions are defined separately from the standard NFT interfaces. You might need to cast to a specific interface that exposes the metadata:
&{FancyRide.NFTPublic}
Lastly, verify that your account has the correct capabilities published. The NFTs might exist in your account, but if the capabilities aren’t set up correctly, you won’t be able to access them through public methods.
hey there brilliantcoder39! i’ve been messing around with nft metadata too, and i totally get your frustration. have you considered that maybe the problem isn’t in your script, but in how the contract handles metadata?
sometimes, nft contracts store metadata off-chain or use a separate resolver contract. it might be worth checking if driverznft does something like that.
also, just curious - have you tried accessing any specific metadata fields directly? like, instead of trying to get the whole nft object, maybe try grabbing just the name or image url?
oh, and random thought - are you sure the nfts in your collection are from the genesis collection? i’ve definitely made that mistake before, trying to access metadata for the wrong set of nfts 
let me know if any of this helps or if you figure it out! i’m super interested in hearing what the solution ends up being.