This primitive allows owner of NFTs, from whitelisted contracts, to monetise their token by staking and minting its Trading Cards which are derivatives of the original NFT and can be a building block for many creative apps (like card battle games, digital autographs etc).
- How it works?
- Rarity
- Interacting with Contract
- Write Methods
- stakeNft
- unstakeNft
- buyTradingCard
- View Methods
- getCardInfo
- Important Events
- NftWhitelisted
- NftStaked
- NftUnstaked
- CardBought
How it works?
Below we describe a typical user flow 🚀
- User stake an NFT from the whitelisted contract’s list, allowing users to mint trading card versions. While staking user specifies
- price for minting the trading card(s)
- rarity of the trading cards which determines the limited minting time and the supply cap of trading cards.
- During the staking duration (determined by rarity) of the NFT, anyone can mint the trading card(s) of a staked NFT.
- The freshly minted trading card(s) can now be used in the intended end-user app like playing card games or shilling digital autograph collection.
- Original user (who staked the NFT) can unstake the underlying NFT and get it back in their wallet once the rarity dependent staking duration is over.
If no one buys a trading card version of a staked NFT within the staking duration, that NFT cannot be staked again later EVER 😰😱 The behavior is intended to create interesting price dynamics.
Rarity
The Rarity of trading card NFT determines the supply cap of the trading cards and the duration for which the Original NFT will be staked to mint trading cards. Owner of the NFT gets to decide the Rarity
of the Trading Cards.
Rarity | Supply Cap | Staking Duration |
0 | 100 | 43200 seconds i.e. ~12 hours |
1 | 10 | 86400 seconds i.e. ~24 hours |
2 | 3 | 259200 seconds i.e. ~3 days |
3 | 1 | 604800 seconds i.e. ~1 week |
>3 | N/A | invalid |
Interacting with Contract
Write Methods
stakeNft
stakeNFT( nftContract, nftId, price, rarity )
Stakes an nft from the nftContract
(must be a whitelisted contract) for the duration and mint cap determined by the rarity
. The price
of trading card is in terms of ETH and is set by the staker (owner of the original NFT). Price can be anything ≥ 0.
Careful consideration should be made while selecting the price and rarity of the trading card, since it is not possible to stake an NFT again if no one buys it originally.
Call Params
Params | Type | Description |
nftContract | address | contract address of the NFT being staked |
nftId | uint256 | token id of the NFT |
price | uint256 | price (in ETH) for minting trading card. |
rarity | uint8 | rarity of trading cards (must be ≤ 3) |
unstakeNft
unstakeNFT( cardId )
Unstakes a staked NFT, returning it to the original staker’s wallet. Can't be called until the rarity dependent staking duration is over.
msg.sender
must be the original staker.
Call Params
Params | Type | Description |
cardId | uint256 | The id of the trading card made from the underlying staked NFT. |
buyTradingCard
buyTradingCard( cardId )
Mints a trading card NFT of the staked NFT. This method can only be called during the staking duration and before the trading card copies exceeds the supply, determined by the rarity of the trading card.
In order to know the correct cardId
to pass to this method, the developer must need to check/index the NftStaked
event.
msg.value
must be equal to the price of trading card set by the staker.
Call Params
Params | Type | Description |
cardId | uint256 | Id of the trading card to be minted. Determined by the NFTStaked event |
View Methods
getCardInfo
getCardInfo( cardId )
Get the full info of the staked NFT associated with a specified trading card.
Call Params
Params | Type | Description |
cardId | uint256 | Id of the trading card for which staked NFT info is requested |
Return Value
Object StakedNFT
with following fields
Name | Type |
tokenId | uint256 |
tokenContract | address |
timestamp | uint32 |
duration | uint32 |
supply | uint8 |
copies | uint8 |
rarity | uint8 |
inVault | bool |
price | uint256 |
owner | address |
Important Events
Developers would need to listen and index the some/all of the following events for various working details in the app
NftWhitelisted
Emitted when an NFT Contract is whitelisted.
Useful to check if a given NFT can be staked.
Emitted Values
Name | Type |
nftContract | address |
NftStaked
Emitted on successful execution of stakeNft()
method.
Useful to get price, rarity, cardId etc info required while minting trading cards.
Emitted Values
Name | Type |
cardId | uint256 |
nftContract | address |
nftOwner | address |
nftId | uin256 |
price | uint256 |
rarity | uint256 |
duration | uint256 |
supply | uint256 |
timestamp | uint256 |
NftUnstaked
Emitted on successful execution of unstakeNft()
method.
Emitted Values
Name | Type |
cardId | uint256 |
nftContract | address |
nftOwner | address |
nftId | uint256 |
CardBought
Emitted on successful execution of butTradingCard()
method.
Useful to know how many copies of the tradingCard NFT has already been minted
Would be useful the end-user app build with trading cards.
Emitted Values
Name | Type | Description |
cardId | uint256 | |
nftContract | address | |
nftOwner | address | |
nftId | uint256 | |
edition | uint256 | copy number of a particular trading card series. 0 ⇒ first copy |