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?
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.
- List down the NFTs the user holds, and get their token ID - You can use The Graph or Alchemy SDK for this.
- Have them transfer to your contract using
approve the transfer.
- Make sure your contract keeps a track of when the user stakes their NFT with the duration to calculate the utilities the user gets.
- 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.