For example, if our lootbox collection has a total of 100 NFTs, and 75 of them are copies of NFT A, and 25 of them are NFT B, then the probability of getting NFT A is 75%, and the probability of getting NFT B is 25%, making NFT B more ‘rare’ than NFT A. To execute this, we’ll use Thirdweb, an easy to use web dashboard for building Web3 applications, to create an NFT ‘bundle collection’, that we’ll use to create a ‘pack’. Each pack will have a randomly generated number which will determine if the NFT inside is either NFT A or NFT B.
The pack contract lets you bundle ERC20, ERC721 and, ERC1155 tokens together into ERC-1155 NFTs that act as randomized loot boxes. When a pack is opened, a pre-defined quantity of tokens are randomly selected from the ones that were used to create the packs (that haven't already been selected), and awarded to the opener. The pack NFT is burned as it's opened.
You can configure how many tokens get selected for the pack: How many tokens are in each "unit" (for ERC-20 & ERC-1155 tokens - one unit could be multiple tokens). How many units are in each pack. You could use the Pack contract to:
- Create randomized NFT loot boxes
- Run a randomized raffle where some users open a winning ticket
- Reward your community with token gift boxes
- Deploy a pack contract
- Mint pack NFTs with other tokens inside them
- Create an app that lets you open them to reveal what's inside