Cowlony smart contract part3
This is part of a series about our smart contract, you can read the part1 and part2 on our medium page. This article is about our staking mechanism, how it works and compares to other implementations. We will try to make it understandable for everyone and also introduce some of the technical details.
Staking in general
In simple terms, staking means getting rewards for locking up assets. In our case locking up means removing from the market for a period of time. We are planning for the long term and to execute our plans we need consistent holders, who are part of the community and not just looking for a quick flip. That’s the reason we want to reward those who don’t list and sell their cows.
With traditional methods staking means putting your coin into a pool and later at the end moving back to your wallet. This way the staked coins are safely locked up. This process could work with NFTs as well but it could have serious limitations because when moving out your NFT from your wallet it is much harder to verify that you are the owner of the staked NFT. It can be important to use the NFT as a pass to enter gated communities or just to show your collection.
Staking an NFT
In the past months, the Moonbirds collection in a collaboration with the divergencetech introduced a different approach to staking. After we read the posts and smart contract regarding this new mechanism we believe this should be the new standard for NFT staking. So that’s why we decided to go with this implementation instead of following a traditional staking implementation. In the followings we will describe what we think is the most important about this new mechanism (this may differ from the opinion of the creators). Also, it is important to establish first this is not our original idea we are using an existing solution.
The most important difference is that a staked NFT is staying in its holder’s wallet, and can be used for verification the same way as any other NFT. The second one is that it is associated with the given NFT and not with a holder. This way the all-time spent in staking can become one of the attributes of a piece. Benefits can be unlocked based on the value of this parameter, so a cow with longer grazing (staking) time can be worth more. The method grants the long-term inclusiveness of the community since new members who join in after a while should not start from zero, their cow will have also an all-time grazing value.
Grazing
Grazing is our term for staking, like when you own a cow you have to graze it and while doing it you could not bring it to the market to sell it. Grazing could be triggered directly through our site or smart contract. While a cow is grazing it is prohibited to list it for sale (our robot will watch the big marketplaces and will terminate the grazing when it detects a listing). They could not be sold, regular ERC-721 transfer function will not work on grazing cows.
Special benefits are tied to specific grazing levels, but there is also an option to specify unique requirements as well. In the following example from left to right you can see that the first two cows need 18 days to achieve the next level (grazing from 13 days). The one in the middle has already been grazed much longer and is currently in the gold level, as new levels start a new grass appears as well. The 4th cow has not started grazing yet and the last is just begun the grazing.
- Bronze grazing level will start one or two weeks after the mint and will last for 30 days
- Silver grazing level unlocks a free list spot for our next collection
- After the mint of our next collection we will distribute 10% of the profits between cows with gold grazing level
These are far from all the benefits and levels but so far we want to reveal just these and keep the rest for later. We are believing in under-promising and over-delivering, and also want to keep some surprises for the future.
Other details
As mentioned earlier grazing is associated with one cow and its parameters are available for everyone:
- grazing status
- current grazing time
- total grazing time (all previous + current time)
- longest uninterrupted grazing
The safeguard for preventing selling is in the overridden _beforeTokenTransfers function. We are checking the grazing status before the transfer and rejecting it when grazing is active. In addition, this also makes it one step harder to steal a grazing cow in case of a hack. We also have a special function to transfer cows to your other wallet while they keep grazing.