metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.32k stars 6.25k forks source link

How to programmatically verify that a token account is associated to a NFT collection created using Candy Machine #1216

Closed macadev closed 2 years ago

macadev commented 2 years ago

Hi Metaplex team, I'll state my question as briefly as I can:

I'm working on a project where the token holders of an NFT collection will be able to interact with another Solana program I am creating. Logically, that other program will have to validate that the transactions it receives come from true owners of a specific NFT collection. This is how I'm thinking of performing that validation:

With the above all that has been accomplished is checking that the Token Account is truly owned by the person sending us the transaction and that it has balance = 1. The piece that I haven't been able to figure out is how to ensure that the Token Account is truly a part of a specific NFT collection. This is one way I can think of doing that:

image

image

My Solana program could check that the update authority and the mint authority match some hardcoded accounts. Is validating this chain of relationships a safe way to prove that a Token Account is associated with a specific NFT? Is there an easier way to do this?

My concern is that since I don't understand the internals of the spl-token program and Metaplex's Candy Machine I'm not sure what parts of this can be easily spoofed to trick my program into thinking a Token Account is part of a valid NFT collection. It feels unsafe to me unless an expert tells me otherwise.

Thanks a ton for your help! I really appreciate it.

DavidBarrick commented 2 years ago

Were you able to figure out a solution to this yet? I'm trying to figure out the same problem.

a-nickol commented 2 years ago

Having the same concerns, here. I think mint authority is for every token different and update authority can probably be spoofed.

stegaBOB commented 2 years ago

You have to validate NFTs using the creator array within the on chain metadata. If the creator has verified=true in the creator array, that address must have signed off on it. Our docs provide a bit more information on this I believe. Our Discord is also a good resource to use. Thanks!