Inspiration

  1. As an NFT owner, do you have NFTs that are just sitting in your wallet and you want to utilize it in a fun way while earning passively from earning this asset?
  2. As an NFT collector, do you ever dream of owning that unique and premium NFT but it's outside your budget?

Enter Gumball Factory, a fun protocol that allows NFT owners to create unique Gumball Machines with a customizable preset chance of winning (via Chainlink VRF) and adjustable entry fees. The Gumball Machine allows other NFT collectors to try to win their NFT by spinning the gumball machine.

What it does

Gumball Factory is a protocol that will allow anyone with an NFT to create a chance for other NFT collectors to win it. Our protocol will create fully unique gumball machines for each NFT which is customized by the NFT owner.

Each machine will have an entry fee, the odds for winning the NFT and maximum entries allowed, all customized by the NFT owner. NFT collectors wishing to try to win it must pay the entry fee prior to spinning the machine. The Gumball machine will use Chainlink VRF (Verifiable Random Function) to generate a verifiable random number which will determine if the user who spins is a winner. If the user is indeed a winner after a spin then the gumball machine will send the NFT to the winner.

What's really neat is that the NFT owner is in control of their gumball machine! The NFT owner can destroy the gumball machine at any time to get back their NFT (provided it's not won yet) and also collect all the entry fees from people who have paid for entries up to that point.

To make this a fun and exciting experience, everyone's a winner in our protocol! Even if the NFT collector doesn't win the NFT in a spin, they win a random prize of GUM protocol tokens. Holders of the GUM tokens can vote on the future of the protocol and tweak possible parameters such as a protocol fee collected on every spin and/or early termination fee by the NFT owner and any other parameters.

As GameFI grows there will be many more game items represented as NFTs = big opportunity here.

How we built it

In order to get a provable random number, we used Chainlink's VRF service to enable true randomness. We have a gumball machine factory contract that will create fully customized gumball machines by the NFT owners.

We used QuickNode to enable a better user experience to display a list of the current gumball machines when a user lands on the page without having him/her connect their wallet first.

We used the Polygon network (Mumbai) to help us quickly deploy and test our smart contracts and to save on transaction fees

We have a factory contract that will spawn gumball machine contracts which are created by the NFT owners. That way we can isolate each machine to the unique of the NFT so that way the owner can have full control over his/her machine.

Challenges we ran into

We wanted to make sure that everyone is a winner by giving GUM protocol tokens to the people that spin and don't win the NFT. To do that, we had to add in a mechanism to ensure that only the Factory contract can mint GUM tokens (since it would be very bad if anyone can mint GUM protocol tokens) and that only valid machines can call the Factory to mint GUM tokens.

We had to learn how to create a Factory contract that spawned sub contracts (Gumball Machines) so we could isolate the machines that can be controlled by the NFT owner.

Accomplishments that we're proud of

As NFT owners ourselves (we're big fans of the Aavegotchi game), we wanted a fun way to allow others a chance to win and also earn passively and the idea for this project was born. We have not worked with the Chainlink VRF mechanism before and we are proud to have integrated the system. It was a blast to do and easier than expected.

What's next for Gumball Factory

  1. After hearing from some NFT owners about how they could possibly lose their NFT on the first spin, we are looking to provide another factory that will allow the user to choose whether there should be a minimum number of entries before the spin happens.

  2. Additionally, we are looking to see how we can use a bridge contract to allow Gumball Factory to be used on other chains such as Ethereum. Due to the high transaction fees in other chains, it might not be feasible to deploy there. Rather, we would have an escrow contract on the other chains that will need a winning ticket to unlock and the winning ticket originates from Polygon (thus keeping the transaction fees low).

  3. As an expansion we are looking at multiple NFTs (think floor NFTs) within a gumball machine so owners can bundle more than 1 NFT to win inside a machine to attract collectors.

Testing

We built a mint function so you can get an NFT minted to your wallet to create a gumball machine.

Before you begin, you'll need some matic for the mumbai test network. Get them here - https://faucet.polygon.technology/.

Gumball Machine Creator

  1. Navigate to the "Faucet" tab. Click the "Connect" button and connect the wallet you want to use. You will need to switch to "Mumbai Test Network". Click on the "Mint a AavegotchiNFT" button. Approve the transactions. View the transaction on the block explorer and find the NFT token ID.
  2. Go back to the home page and click "Create gumball machine". The NFT contract will be pre-filled. Enter the NFT token ID you copied from the transaction. Enter the entry fee, maximum entries and chance of winning.
  3. Click the "Create Gumball machine" button once you've entered all the fields. Approve the transactions.
  4. You now have a gumball machine!

Gumball Player

  1. You'll need DGHST for this. Navigate to the "Faucet" tab. Click the "Connect" button and connect the wallet you want to use. You will need to switch to "Mumbai Test Network". Click on the "mint 1000 DGHST".
  2. You'll receive 1000 DGHST in your wallet.
  3. Go back to the home page. Choose a gumball machine you want to spin. Approve the tokens to be used then once it's approved, press the "spin" button. The gumball machine will pop up and your prize will be revealed.

Built With

Share this project:

Updates