NFT staking problem

Hi!

I have a little bit of a problem, i built a NFT staking dapp and i used the walletOfOwner function to get the token ids of the NFTs in the wallet. But the NFT contract doesn't have that function. I tried to use a text input where the user has to type in the token ids but it gives me a t.map error. Can anyone help me?

Hey dudicslevente,

NFTs follow either standard ERC-721 or ERC-1155, so be sure to check out the public functions they have that you can use.

Staking is a bit complicated, however I'd divide it into few steps.

  1. List down the NFTs the user holds, and get their token ID - You can use The Graph or Alchemy SDK for this.
  2. Have them transfer to your contract using safeTransferFrom, or approve the transfer.
  3. Make sure your contract keeps a track of when the user stakes their NFT with the duration to calculate the utilities the user gets.
  4. Transfer the NFT back to the user when the user requests the NFT back with the utilities if there is.

This is just one way to do this. Pretty sure there are more amazing and better ways. Do your own research.