Are You Building a Blockchain-based Game?
We just open-sourced our Ethereum blockchain in-app purchase solution, after 6 months of writing and testing the contracts and front end to support the functionality.
The goal is to allow game development teams to avoid building their own system for in-app purchases when instead they could be devoting that effort to making a greater game. That’s why I wrote In-App Pro Shop.
The system consists of a set of Solidity contracts and a React-based web app that allow anyone to create a Shop, specify a fiat currency for setting prices, and stock their Shop with items to sell. Doing so only costs the gas price of your Shop maintenance transactions, which I’ve optimized as much as possible.
What Does a Shop Actually Sell?
Items are minted as ERC-721 NFTs, just like CryptoKitties. The currency symbol is IAPS. As such, they can be sold, traded, or even rented out by their owners. They can be rare (e.g., you can set a limit to how many can be minted), and they can be consumable (e.g., after you drink a magic potion, you can’t use it again). Once a user owns a token, only they can transfer it to another user. And since it’s on the blockchain, it’s theirs to do with what they will, forever.
Interestingly enough, game developers could even choose to allow assets from other games to be used in their own, the way CryptoKitties can be used in various games in the “Kittyverse“.
Ethereum is Volatile, Won’t that Be a Problem?
Prices are set in a stable fiat currency, like USD, so you don’t have to change them every time the value of Ether skyrockets or nosedives. If the price were set in Ether, then market fluctuations could suddenly make the item prohibitively expensive or dirt cheap. That makes it difficult to forecast revenue. If you expect a Magic Sword to cost 5 bucks, then that’s what it will cost. This also avoids the need to come up with your own “in game currency.”
As soon as someone purchases an Item from your Shop, you can withdraw the Ether to your Ethereum address. At the time of a sale, the purchase price is converted to the latest Ether quote from FiatContract. A small (3%) franchise fee goes to my little company and the balance goes to the Shop Owner.
The fee ensures that Futurescale can donate regularly to FiatContract in order to keep it active. It is an “oracle” contract which is updated from an off-chain application each hour with the latest quotes. That has gas costs associated with it, and so it requires donations to stay alive.
What’s the Status and Where Do I Sign Up?
The project is now available on GitHub and you can run it locally while doing development. At the time of this writing, the contracts and maintenance app work, shop balances can be withdrawn, unit tests for all functionality (i.e., creating and populating Shops, minting new Items and adding the balance after the franchise fee to the Shop Owner’s account, checking getting the price in Ether for an Item from FiatContract, etc.) all work as expected But it has only been tested on a local node, not on the test or main nets. This means you have an opportunity to help shape the final product.
If integrating with In-App Pro Shop sounds interesting to you email me, and if you’re serious, I’ll work with you personally to help get it integrated into your app. Or if you’d like, head on over to the project site and read up on how to get the contracts and maintenance app running locally, and start integrating with the contracts on your own.
JAN
2019
About the Author:
Since the early ’80s, my consuming passion has been programming. Today I work as a Software Architect, bringing more than 30 years of industry experience to bear on every task. My career has run the gamut from writing games in machine language for Commodore 64 and Apple II to implementation of large scale, object-oriented, enterprise applications. In my spare time, I am an author and occasional music producer.