Staking NFTs and earning rewards is a new way to earn passive income and is used very commonly in the web3 space.
A common issue when trying to stake an NFT using staking contracts is as follows:
execution reverted: Not owned or approved
How to Stake NFTs using
To get started, here's a quick overview of how to stake NFTs:
- Deploy your NFT/token contract and mint tokens
Deploy here: ERC721 NFT Drop ERC1155 Edition Drop ERC20 Token
- Deploy your staking contract that matches the token standard deployed above.
Deploy here: ERC721 Staking ERC1155 Staking ERC20 Staking
- To stake your NFTs, you need to approve the staking contract within your NFT contract. If you want to stake a single NFT, call the
approvefunction in your NFT contract. This function grants permission to the staking contract to handle the staking process for that specific NFT. On the other hand, if you want to give access to all the NFTs from a particular collection, call the
setApprovalForAllfunction in your NFT contract. This function allows the staking contract to handle the staking process for all the NFTs in that collection. For a detailed example and troubleshooting tips, please refer to the troubleshooting section below.
- Enter the NFT/token parameters into
stakefunction of your deployed staking contract, and execute.
Not owned or approved Troubleshooting
If you are reaching an
execution reverted: Not owned or approved error after following these steps, please verify the following:
- Ensure that you have enough funds in your account to pay for gas fees
- Ensure that you own the particular NFT that is being approved
- Verify that the staking contract has been granted approval on the NFT contract and the approved boolean value has been set to
true. See the image below for an example.
- Confirm the parameters you’re entering into your staking contract meet the required formatting. For example:
- the token ID field inside the
stakefunction requires [brackets] like this →
0to stake token ID 0.
If you are still encountering any errors or issues after trying these solutions, please reach out to our team for assistance or get help from the community in our Discord.