1

I am creating a smart contract where I want user to burn their nfts they are holding to do something. Now how do I do this using my own smart contract given they provide the nft address? Can anyone help me with the code?

We assume it is an burnable nft.

Thanks

1
  • Did you use ERC721 Standard code for your NFT? if not share your code
    – Alireza
    Mar 18, 2023 at 11:10

1 Answer 1

2

I don't think this is going to work simply. Because the user will need to approve your contract to manage the tokens and then your contract can burn the tokens on behalf of the user.

For this you either need to provide them a UI to call the approve function or they need to call it from etherscan.

2
  • Okay so for the UI part can you provide the function logic of how to approve the smart contract in the backend? Mar 21, 2023 at 17:29
  • Just like any normal contract interaction, using ethers or any library. the only thing to keep in mind is the approve function must be called by the user so that user becomes msg.sender in the NFT contract. Mar 22, 2023 at 10:25

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.