Find ORE in-game by breaking blocks and EXTRACT it to an ERC-20 ORE token using Chainlink ANY API.
SMELT ORE tokens into random METAL tokens such as rare PLATINUM or common IRON by making a Chainlink VRF request.
MINT NFT items with varying QUALITY SCORES and COMBAT RATINGS based on the results of a Chainlink VRF request.
The METADATA for the NFT items is determined by the results of the VRF request, encoded to BASE64, and stored on-chain.
Mine Labor Simulator is an ACTION packed PLATFORM game. Players fight for survival and work to discover ORE tokens.
I have been building browser games for over a decade. I realized that Chainlink unlocks the potential for more advanced Web3 gaming. I wanted to prove this concept with a simple browser game that does some cool stuff with oracles and smart contracts.
What it does
Mine Labor Simulator allows players to find and MINT ORE tokens. These in-game ORE tokens, which live on the server, can be extracted into ERC-20 ORE tokens, which live in the player's Web3 wallet.
The ERC-20 ORE tokens can be SMELTED in-game into METAL tokens such as PLATINUM, GOLD, COPPER, NICKEL, and IRON, which are also ERC-20 tokens. These METAL tokens have varying rarity determined by a smart contract and the results of a Chainlink VRF request.
These METAL tokens can be spent by players to produce NFT items. These NFT items have varying QUALITY and COMBAT RATING scores, which are also determined by the results of a Chainlink VRF request.
How I built it
To MINT the NFT items, I once again use a Chainlink VRF request. This time I request two numbers that are used to determine the QUALITY SCORE and COMBAT RATING of the item.
The METADATA for the NFT items is stored on-chain. The METADATA includes the ITEM DESCRIPTION, which is generated by a smart contract based on the results of the VRF request. The complete METADATA JSON is encoded to BASE64 and stored in the TOKEN URI of the NFT.
Mine Labor Simulator uses the ImpactJS Game Engine and other open source technologies such as the OpenZeppelin Contract Library for token standards, encoding Solidity to BASE64, and working with Strings. I used assets from my other games so that I could focus on writing smart contracts. I also used Uniswap V3 for purchasing LINK tokens on-chain to defer the costs of the oracle requests to the player.
Challenges I ran into
Accomplishments that I'm proud of
For the last few years, I've been thinking about ways to use crypto assets in games. Yet, I never took the initiative to actually build anything. I'm proud that I stepped up and created all the functions that I have been dreaming about and put them into a game.
What I learned
I learned that integrating Web3 into gaming is fun and easy. There are some additional security considerations to make the in-game economics a little less gameable in production, but I'm already thinking about this in depth. Through the use of real-world identity and rigorous and frequent server-side checks, I think I could make a pretty secure in-game economy.
What's next for Mine Labor Simulator
This game could be extended beyond a demo to include multiple levels and different towns and stores to create a game world similar to Castlevania 2. Or it could be turned into a minigame as part of a resource-driven metaverse world. Regardless of where this particular game goes from here, the concepts that I learned and practiced are invaluable and could be applied in many places.
Thank you for checking out my project! You can contact me here if you are interested in working with me.
Smart Contracts on Etherscan
Check out all the Smart Contracts used in this project on Etherscan:
ORE MINTING Contracts
- Wrap Eth and Pass to Swap Contract
- Swap WETH for LINK Fees and Pass to Minting Contract
- GET Request to the Server Using Chainlink Oracle and ANY API
- Ore Token Contract
ORE SMELTING Contracts
- Smelting Contract
- Swap Contract to Fuel the Smelter with LINK Tokens
- Iron Token Contract
- Copper Token Contract
- Nickel Token Contract
- Gold Token Contract
- Platinum Token Contract
NFT Item Making Contracts