Inspiration

I was working on an NFT card game and was disappointed when there wasn't a ready made solution for random loot boxes. So I made one.

What it does

Random Box provides a public smart contract that allows for construction and opening random loot boxes. As a smart contract developer, you can use the API to put ERC721 compatible tokens inside a Random Box, which is another ERC721 compatible token. The box holder can use the Random Box app to inspect the contents of and open the Random Box to get one random NFTs of the NFTs inside.

How we built it

Random Box is a smart contract made in solidity and deployed with Hardhat. The app is made in React, using the Moralis API to fetch NFT data.

Challenges we ran into

Moralis is currently having some issues on Rinkeby so I added an option to use the OpenSea API for testing on testnet. Mainnet can still use Moralis though.

Accomplishments that we're proud of

Really proud of the automatic documentation of the Random Box smart contract. I wrote the comments in natspec and they were generated by hardhat-docgen.

What we learned

Learned:

  • How to use Chainlink VRF
  • How to use Moralis Web3 API

What's next for Random Box

Want to make it so the box creator can retrieve the other NFTs. Maybe this will allow for more use cases. Also want to deploy on mainnet. But the gas costs so much 😭. So probably polygon actually. That's where my card game is deployed (and most games).

Built With

Share this project:

Updates