While we make ChatPuppy NFT
, we keep in our mind that we should solve the following problems:
- How to make the features of NFT more interesting and fun.
- How to make NFT’s attributes more credible.
- How to mint NFTs more decentralized.
- How to make NFT more valuable, immutable.
- How to trade NFT easier.
- How to make NFT more versatile and connectable to third-party platforms such as
OpenSea
,LooksRare
, etc.
To solve these problems, we adopt the ChainLink VRF
random number oracle, which generates random attribute data(metadata) of NFTs on the blockchain by smart contracts. These metadata determine the avatar image, level and other attributes of NFTs.
This mechanism of ChatPuppy NFT
is different from the existing popular centralized approach of having the issuer minting NFTs and then setting the Metadata artificially for each NFT, which is a decentralized, fair and trustless NFT generation solution.
The purpose of this paper is to introduce the technical solution. Programmers can design a variety of innovative NFT products by understanding the ChatPuppy NFT
.
1. ChatPuppy NFT modules
ChatPuppy NFT
consists of the following modules.
1.1 Mint
Anyone can pay a small amount of ETH
for an NFT Mystery Box
, which based on ERC721
protocol. Before the Mystery Box
is opened, the metadata is zero. Only after the box is unboxed, the metadata (i.e., the attribute value of the NFT) will be randomly determined.
The Mystery Box
is a ERC721
token(NFT), user can get the metadata by calling tokenMetaData
function of the smart contract. After it is unboxed, you will get metadata of the NFT a value similar to 0x05460006010607060306
. This is generated on the blockchain by ChainLink VRF
. This metadata is immutable, nobody can amend it.
Smart contract developers can define this metadata structure by themselves. The contract that defines the metadata is ItemFactory. After the contract is deployed, the developer can define NFT’s properties by calling addBoxType
and addItem
functions.
1.2 Profile
This module is used to manage and display NFTs in the wallet.
- Display
TokenId
, image, level, experience and metadata of NFT. - Sell NFTs.
1.3 Marketplace
- Display
TokenId
, image, level, experience and listing price - Buy NFTs
- Update price
- Unlist NFTs
1.4 Chat Dapp
As whitepaper mentioned, The NFT avatars are shown in the ChatPuppy Dapp
, NFTs of different level and experience will have different features.
2. Traits of NFT
2.1 Traits
Each NFT has 6 traits:
- Background
- Body
- Eyes
- Fur
- Head
- Mouth
Each traits has several items of different Rarity
, Level
, and Experience
properties.
Different combinations of trait’s items are generated by an blockchain-based random number generator oracle. Totally up to 100,000 different ChatPuppy NFTs, each with a different Image
, Rarity
, Level
, and Experience
.
2.2 ChatPuppy NFT traits table
Note:
- The sum of the rarity of items for each traits must be 100%.
- Experience and Rarity are roughly inversely proportional.
- We can get totally
6 * 6 * 7 * 11 * 6 * 6 = 99792
NFTs.
2.3 Traits on blockchain
The following script is set with traits data from above table, all data will be updated to blockchain by web3.js
or ethers.js
. After the traits and items data are initialized, can be update.
export const itemParams = [{
boxType: 2,
boxName: 'Background',
itemId: 1,
itemName: 'Blue',
rarity: 280000,
level: 1,
experience: 0,
}, {
boxType: 2,
boxName: 'Background',
itemId: 2,
itemName: 'Orange',
rarity: 230000,
level: 1, experience: 20,
}, {
...
}, {
boxType: 7,
boxName: 'Mouth',
itemId: 6,
itemName: 'Gold',
rarity: 120000,
level: 1,
experience: 160,
}
];
Please refer here to get the source code of the script.
3. Parse the metadata
Taking metadata 05460006010607060306
as an example, according to this metadata, we can derive avatar image, level, experience value etc.
0546 0006 01 06 07 06 03 06
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ └--Background#6
│ │ │ │ │ │ └--Body#3
│ │ │ │ │ └--Eyes#6
│ │ │ │ └--Head#7
│ │ │ └--Fur#6
│ │ └--Mouth#1
│ └--Level=0x0006=6
└--Experience=0x0546=1350
Check the properties from above traits table, we can get.
Level is 6
, Exp is 1350
(Hex 0x0546
), avatar image is:
To secure the attributes of NFT and avoid from maliciously tampering with the attribute values, we caculate the level and experience in the smart contract and store the values on the blockchain.
4. Range of rarity and experience
4.1 Rarity
To help users understand the attributes of ChatPuppy NFTs and evaluate the value of their NFTs, here is the way of caculation of rarity.
The rarity of each NFT is the product of six traits’ rarities. Taking the above metadata 05460006010607060306
as an example, we get:
That means there probably 2.2464
NFT will be same in 1,000,000
NFTs. Consider we only have 99,792
NFTs, there is no possibility to get same NFT.
4.2 The rarest NFT
The lowest probability (the rarest) is: 0.0000000360
, that is 3.6 in one billion
, the corresponding metadata is: 0x0CF80006050408030506
4.3 Experience probability distribution
(Experience pareto distribution)
80%
probability is exp: 350-1300
.
4.4 Rarity probability distribution
(Rarity pareto distribution)
50%
probability is 0-25
, means 0-25
same NFTs in 1,000,000
. Consider we only have 99,792
NFTs, there will be maximum 2.5 same NFTs.
5. On chain randome generator
The key in the implementation scheme is how to generate random numbers in the smart contract to produce metadata attributes. Thanks to ChainLink
for providing a random number scheme based on VRF (Verifiable Random Function)
, which allows us to generate random numbers on blockchain, thus making NFT casting more interesting and trustworthy, and truly decentralized.
Recently, ChainLink
has launched VRF V2
. Refer here
If you want to know how ChatPuppy NFT
call and implement randomness in smart contract, please refer to the smart contract on my github repo:
6. Metadata on-chain or off-chain
Currently, the way of trading on NFT marketplace such as OpenSea
is basically that the issuer issues thousands of NFTs, and then opens a store (Collection) on Opensea
to put these NFTs and start selling them.
Most of the NFT metadata is not stored on the blockchain, but on the issuer’s servers and save the picture on IPFS. The metadata attributes of these NFTs can be modified by the publisher. Thus there will be potentially risk.
In addition to this, many GameFi also generate random properties of NFTs on their server. This are inherently centralized, and because of this, the main approaches have been criticized and have resulted in a lack of real protection for the value of NFT assets.
The key to solving this problem is how to generate NFT properties directly on the blockchain, and we are glad to see that the Loot
has proposed an interesting thing to solve this problem: issuer-defined NFT features. However, Loot's features are still defined by the issuer, can not avoid modifying.
ChatPuppy NFT
provides a new solution for NFT as well as GameFi by defining feature values on blockchain through ChainLink VRF
random number oracle.
We believe the metadata-based NFT
will be more valuable than the picture/video NFTs soon.