Skip to content

Web 3 game and project for Chainlink Fall 2022 Hackathon.

Notifications You must be signed in to change notification settings

Donzo/Mine-Labor-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mine Labor Simulator

Web 3 game and project for the Chainlink Fall 2022 Hackathon.

Play Now

Image

Prove your work by mining blocks at Mine Labor Simulator.

Mint Ore Tokens with ANY API Request

In this game players break blocks with a pick axe. Some blocks contain ORE tokens. ORE tokens are stored serverside in the database until the player MINTs them.

In order to MINT the ORE tokens, the player wraps ETH and swaps it for LINK tokens. The LINK tokens are sent to the MINTING contract, which uses ANY API to GET the player's ORE balance and MINTS that amount of ORE tokens.

Contracts for MINTING ORE

The contracts for MINTING ORE have been deployed on Goerli. View them here:

  1. Wrap Eth and Pass to Swap Contract
  2. Swap WETH for LINK Fees Contract
  3. GET Request to the Server Using Chainlink Oracle Contract
  4. Ore Token Contract

After minting the ORE tokens, the players in-game ORE balance drops to zero. The ORE tokens now live in the player's Web3 wallet. But what can the player do with ORE tokens?

Smelt Ore with VRF Intgration

Image

Once the player's ORE tokens have been minted into their web3 wallet, they can SMELT their ORE tokens. Players goes to the blacksmith shop in-game. In this shop players are presented with the option to SMELT their ORE tokens.

The process of SMELTING ORE involves transferring the ORE tokens to a smart contract, which makes a Chainlink VRF request. Before doing this, the player swaps some ETH for some LINK to FUEL THE SMELTER.

Once the smelter has been fueled and the player has transferred his or her ORE tokens, the SMELTING contract makes a VRF request. Based on the result, the SMELTING contract will MINT one of several METAL tokens of varying rarirty: IRON, NICKEL, COPPER, GOLD, or PLATINUM.

Contracts for SMELTING ORE

The contracts for SMELTING ORE been deployed on Goerli. View them here:

  1. Smelting Contract
  2. Swap Contract for Smelter
  3. Iron Token
  4. Copper Token
  5. Nickel Token
  6. Gold Token
  7. Platinum Token

After SMELTING the ORE tokens, the player will no longer have ORE tokens in his or her wallet. Instead the player will receive METAL tokens based on the VRF result. These METAL tokens will live in the player's Web3 wallet. But what can the player do with METAL tokens?

Create NFT ITEMS with VRF Integration

Image

Once players have METAL tokens created from smelting ORE tokens, they can visit an in-game store to create NFT Items. These items vary by TYPE, MATERIAL, QUALITY, and COMBAT RATING. The TYPE of item is chosen by the player based on how many METAL tokens he or she is willing to spend. The MATERIAL is determined by which METAL token the player will spend to create the item (IRON, NICKEL, COPPER, GOLD, or PLATINUM). The QUALITY and COMBAT RATING of the items are determined by Chainlink VRF requests.

The results of the VRF requests are used in the NFT Item metadata, which is encoded to Base64 and stored onchain.

  1. NFT Items ERC 721 Contract
  2. NFT Description Generator
  3. VRF Request and Item Maker Contract
  4. View the Project on OpenSea Testnet

Technologies

Image

This project was made possible by Chainlink and open source technologies. I used ImpactJS for the game engine and the Web3JS plugin. I integrated existing assets from my other games so that I could focus on engineering the smart contracts. I used Uniswap V3 to purchase LINK onchain. I used many OpenZeppelin Libraries and Standard Deployments. I'm using a MySQL database to store ORE token counts prior to MINTING. And I'm using PHP to perform serverside checks and to connect to the database.

I hope you like my project.

About

Web 3 game and project for Chainlink Fall 2022 Hackathon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published