How does NFT staking work

Staking is another function that has become very popular right now. In my article on "How Smart Contracts Work" , I explained to you how NFT smart contracts work. If you have not read it make sure to check it out before you continue on this one.

Today I want to show you how staking works on the example of Wizard & Dragons Game. For that, we need to look at the smart contract using Etherscan. Make sure to always get the official contract from the right collection on Opensea, either from the discord or from the webpage.

Once you have that you can go to the tab “contract” which allows you to see the code they have deployed. What happens with staking usually is that the team has several contracts that work in tandem together. On their discord you will see that the team has deployed several contracts.

You have an NFT contract, which just stores the ownership, points to the metadata, the file and so on (check out Article #8 for more details on that one). The WnD Project Team has another smart contract that is used for the staked NFTs. You can view that contract if you go to the tab “Read Contract” and view the function “tower”. This function points to a different smart contract used for staking. Important note: this function must not be named “tower”. The team can decide upon the name as well as the address of this contract. By clicking on the link, you can view this contract.

Also the function for staking is named by team and this time called “addManyToTowerAndFlight.” In order to stake the NFT this contract calls the “transferFrom” function from the original NFT contract.

The “transferFrom” function is pretty standard in ERC20 & ERC721. You can view it in the original NFT contract in the tab “Contract” > “Write Contract” > "#13 “TransferFrom”

This function allows you to transfer a certain Token ID from one address to another address. Of course not everybody can do that as that would be a security risk. However, within the described function the message sender that is you can transfer a certain token ID to the Tower contract for staking. This means that after you executed this, the staking contract is the owner of the NFT. This is fascinating to understand because that means that the contract has to remember who the owner of a certain NFT is. So when you get it back out of the staking contract it needs to know that information.

While the NFT is staked, it cannot be sold (cause the staking contract owns it until you get it out). So you are not creating any selling pressure on the collection. However, why should a user stake his NFTs? Usually you get rewards for staking your NFT. This can be done in different ways but the essence is always the same. Usually you have a claim function which allows you to get your rewards in forms of token.

You have a function that calculates the rewards based on e.g. a timestamp.

And they have a separate token on a separate contract which is directly minting these token to your address. So whenever you claim it then it will send you some of your tokens. (row 178)


Staking is achieved by several smart contracts interacting with each other. Staking temporarily transfers the ownership of the NFT to the staking contract meaning that the real NFT owner cannot sell the NFT. In return, the NFT owner receives rewards that can be used for different things.

All in all, I hope that this article gives you a better insight into how NFT smart contracts work. Also, I hope you learned something today and would love you to consider following me on my twitter @0xCryptonite if you like more recent upd

Back to blog