0

GM community,

My aim is to mint NFTs via smart contract and in the future identify if those NFTs are minted by my smart contract. I can possibly set update authority and mint authority to my smart contract's minted NFTs. However, I think it's possible to change any NFT's mint/update authority, which will allow any NFT to mimic and get approval from my smart contract.

Let me know if my understanding is wrong anywhere, or if there is any way to achieve this.

2 Answers 2

1

One simple way to do this would be to check the mint authority.

Specifically, when you set up an NFT minting program, you have to disable minting as soon as the NFT has been minted. It looks like this with Anchor:

(NFT is minted to a wallet)
...

token::set_authority(
    CpiContext::new(
        ctx.accounts.token_program.to_account_info(),
        token::SetAuthority {
            current_authority: ctx.accounts.mint_authority.to_account_info(),
            account_or_mint: ctx.accounts.mint_account.to_account_info(),
        },
    ),
    AuthorityType::MintTokens,
    None
)?;

Disabling minting just means you're setting the mint authority to None. That way, nobody can ever mint that same token again (non-fungible).

Your program could then have a function that just checks to see if that NFT's mint authority has been set to None. Perhaps with anchor_spl::token::accessor::authority?

1
  • But would it not be possible for an impersonator to create a random NFT -> set authority to None -> cheat my smart contract to approve that NFT as valid Jul 21, 2022 at 12:03
0

You can mint an NFT by doing CPI to the token-metadata program and SPL Token Program. To understand it more there is an article on how to do this. Adding more to your question you can for sure put your program as the update authority but mint authority is assigned to the token-metadata program so you cannot change that

2
  • yes, I am able to mint the NFT via smart contract. I want to create a logic to identify if a certain NFT has been minted via my smart contract or not. Wouldn't it be possible for an impersonator to create a NFT set update_authority to my smart contract and fool my smart contract to validate the NFT. Jul 21, 2022 at 12:05
  • You can do more checking like Checking the Verified Creator field and the collection field because if its your collection than only you can add more NFTs in that collection
    – Pratik.js
    Jul 21, 2022 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.