0

Let's take an imaginary situation where I created a smart contract, through which users minted their NFTs and after some time users transferred their NFTs to the contract address. Now is there any way how I can have access to those NFTs?

1 Answer 1

1

If a contract is the owner of some NFT, the answer to your question depends on the implemented contract functionality. If the contract has functionality to transfer the NFTs onwards, then it can do that. But if there is no such functionality, the NFTs will remain there forever and they can't be moved. Yes, the NFTs will still "exist" and the contract will still own them, but it's a bit questionable whether they are useless or not (can be considered burned or not), at that point.

Some reference code:

function transferNFT() public {
  // import IERC721 from OpenZeppelin for example
  IERC721 contr = IERC721(address_of_the_nft_contract);
  contr.transferFrom(address(this), some_receiver_address, nft_token_id);
}

Code explained:

  1. Use an interface for the NFT contract. You also need the NFT contract's address to create the reference. You can find the interface for example from https://github.com/binodnp/openzeppelin-solidity/blob/master/docs/IERC721.md
  2. Call the NFT contract's transferFrom functionality, transferring a specific NFT (identified by nft_token_id) from the current contract address(this) to some receiver.
2
  • Thanks man!! For better understanding can you please share some code snippet of the transferring functionality. Thanks again! Commented Feb 10, 2022 at 8:06
  • 1
    added some reference code Commented Feb 10, 2022 at 8:12

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.