This article was posted on Medium by FunFair founder Jez San on 20 April 2017. Subsequent development milestones mean that we have implemented more advanced solutions than some of those discussed below. For more information, see notes in the relevant sections.
First Demonstration of real-time casino games built with Ethereum Smart Contracts
FunFair is an online casino games technology and development company building both a platform and a suite of high quality leading casino games. Funded by angel tech investors — and now ready to ‘show n tell’.
We’ve been in stealth mode for a while — building our technology and games and its taken almost a year but we’re finally ready to start showing what we’ve been working on. We’re over the hump in terms of R&D. We’ve solved some big tech issues and feel we’re at the stage where the work is ready to show and solicit constructive feedback with a view to releasing the games later this year.
We’re a proven team of professional computer games / gaming developers. A mix of old and new. Some of us have been around a long time — since the early computer games that you might’ve played as kids.
My first game was in the 80’s (!) — StarGlider on the Atari and Amiga computers. In the 90’s my team at Argonaut produced some of the first 3D computer games on games consoles like Nintendo and PlayStation, and we also designed the first 3D graphics accelerator chip (GPU) for games systems (the Super FX chip for the 16 bit Super Nintendo entertainment system). We used the 3D chip to build the StarFox game amongst others.
We built one of the first 3D platform games (Croc) on PlayStation and some of the most successful platform games like Harry Potter — each of those games sold millions of copies… but enough about retro games, which I could go on about for hours.
I’ve also been into technology and silicon design. One of my startups — ARC International produced the first customisable risc microprocessor which is still in use today inside many of your usb sticks, sd cards, and also inside almost every Intel microprocessor (!)
I got into Bitcoin in early 2013… attended the San Jose Bitcoin conference that year, and have joined most bitcoin conferences ever since, often as a speaker or panelist talking about mining — I mined professionally during late 2013 and 2014.
When Ethereum was announced in Miami at the TNABC, I was there – an exciting time! Several of my bitcoin friends were early founders. I participated in the crowd sale and still hold Eth today (and very happy 😉
We love innovation, games and gaming, and Ethereum with its Smart Contracts seemed like a natural home for us.
Our early work in Ethereum was figuring out what was possible to do on-chain and what room for innovation was possible in the space occupied by the DApp and the Smart Contracts.
Above all our mission was to make the games entertaining to the mass market — not aimed at fellow geeks (like us). To make them FUN they clearly had to be fast and responsive but also look good, play well and generally do all the things that the blockchain based games to date haven’t done. Above all we couldn’t have the games running in lockstep with the blockchain (like everyone else seems to be doing). The games shouldn’t be impenetrable so that you need to know about blockchains to play them.
Ethereum’s block time might be fast compared to Bitcoin but no one wants to wait 15+ seconds for each ‘go’ in a game and this might get longer as we approach the ice-age. Often with naughty miners mining zero transaction blocks (because they can) it could easily be double or treble that. Repeating the mantra that it has to be FAST… and FUN. The games have to play like the very best of breed out there and not like some sucky compromised game.
With those goals in mind we figured out that the games have to run asynchronously from the blockchain yet all events, outcomes, game decisions and payouts had to be on-chain and provably fair.
Why Provably Fair?
The game’s logic has to be wholly processed within the smart contracts so that anyone who wants to can see that the game is playing by the rules and can’t cheat… this would differentiate our games from the early online games (dinosaurs?) of the past where the games operate inside a black box on a secret server hosted in a datacenter on some shady island no one’s ever heard of and regulated in jurisdictions equally unknown and their operations would be opaque to the players. If the incumbent online casinos wanted to cheat the players it was all too easy since the games weren’t transparent to the players and were unauditable by anyone except the regulator. And some regulators were better at doing it than others. Even the best regulators can miss something deliberately put in by a sneaky programmer who’s good at obfuscating code.
We’ve seen a few of what we would call early ‘science experiments’ done so far on the Ethereum blockchain. These were smart contracts proving that ‘gaming’ was possible but most of them were shockingly unplayable and at best they proved you could indeed execute & regulate the gameplay in a smart contract but those games didn’t prove you could make the experience fun enough that people would want to play — a prerequisite.
We’ve focussed our efforts on making our games responsive to the players — fast & fun — and building out a platform that supports multiple games and technology components. Part of that platform puzzle is how to generate random numbers to deliver ‘just in time’ to the games that are provably fair and yet fast enough to enable highly responsive real-time games.
The Slot Machine
Our research and development effort over much of the last year has culminated in our first game that’s competitive with any out there in the online casino world. This first game is a fully working slot machine at casino levels of sophistication and math model. It has five reels thirty win-lines and mini-games just like the ones you play in a Las Vegas casino. This isn’t your grandma’s three-reel one-win-line slot machine. Needless to say it has smooth fast graphics and audio/music. Its been improving over these last few months and is already near production ready with hopefully just a few tweaks and it’ll be good to go. This is the first of several different Slot games we have in development — The market likes variety.
Smart Contract gaming
The innovation here is that this game is running entirely in a smart contract. No servers are required to operate the game, unlike existing online casinos. There are no existing online games that run without servers. Even the bitcoin ones still operate the same as the older online games just that they take bitcoin instead of dollars, but they still process and execute the games on private secret servers in black box code that no one can scrutinise and the output of which is hard to prove fairness. Sure they can prove randomness but not what the game actually did with those random numbers. The games and platform we’re building are fully decentralised and provably fair. It supports full quality casino level games and our goal is to deliver games at the highest quality to compete — not with other blockchain gaming companies — but compete directly on their own terms with the incumbent online casino games.
The games all run in any web browser with HTML-5 and don’t require Flash (which already separates our games from most). It opens up the mobile markets because they don’t run Flash anyway which lets them run on the widest set of devices. No gaming servers makes them incredibly fair and provable/audit-able by running on-chain in smart contracts with the added benefit of lowering the operating cost of providing games. (okay, so we’ll pay gas instead of hosting servers). We’ll pass on the savings to the players in the form of improved payouts so the games will be commercially as well as sonically/graphically competitive and performant.
Random Number Generators.. an ongoing project
In this prototype Slot machine game we’ve used an RNG that is generated by the blockchain itself utilising the block hash from the block the bet is in. This RNG method has been proven reliable and fast by some other early games on Ethereum (like Rouleth) but has one teensy weakness we’ll mention later which makes it unusable for us in a production environment.
We developed methods of allowing game-play to appear realtime — more so than any DApp has achieved so far. The goal as game designers is to overcome the latencies present in the system and disguise them when we can’t overcome them. To the end user these games look and feel every bit as good as the games they’re already playing except they’re a better deal (lower house edge = higher chance of winning).
Why Slots first?
The choice of first game in our case was driven by a primary reason. Slots are the most popular games in casinos (in the west) by a large margin. Slots are also quite complex in terms of math and implementation so if a Smart Contract could cope with all the processing and be able to evaluate those win-lines in a reasonable amount of gas then simpler games like Roulette, Dice or Lottery would be almost child’s play. Some of our contemporaries have focussed on less popular games first — perhaps they didn’t see the memo. We’ll develop games in order of popularity because we’re aiming squarely at the mass market.
One innovation we’ve made here makes the slot machine game quite realistic by allowing players to insert ‘coins’ into the machine to play. Supporting the insertion of multiple coins allows longer play sessions without having to reconfirm your bet or interact needlessly with the Ethereum browser and yet it’s still on-chain and provably fair. This is one of several techniques we’ve developed to make the games more responsive for the player.
There’s two parts to each game — the Smart Contract that executes the game, controls how its played, generates random numbers, evaluates wins, decides outcomes and of course pays out winnings to players, and then there’s the DApp that contains the player facing fun stuff — the User Interface — fun, fast and responsive and of course it has to play well. We’re game designers… making something entertaining is the highest priority for us and we know it will be important for our players too.
DApps and Smart Contracts
In our games the DApp and the Smart Contract interact and share responsibility at a fundamental level — far closer than most DApps and Smart Contracts of other Ethereum DApps that we’ve seen. Enjoyable play required we develop some unique methods to make it seamless. For a start -they’re asynchronous — sometimes the DApp runs a little ahead of the Smart Contract or vice versa… but the player doesnt want to concern themselves with the inner workings of the DApp and what’s going on under the hood. Players want to be entertained and not troubled by ‘details’. Its up to us — the game designers — to deliver an entertaining game to them in a fair way and hide the techy details behind slick graphics and sound.
Our players shouldn’t need to be rocket scientists to understand whats going on and get enjoyment out of the games. Ethereum is the backbone to our games, it helps power them quietly behind the scenes but in our case we’ve chosen to keep it somewhat transparent and hidden to the player. The games are designed for the mass market and many of the players will be using Ethereum for the first time without even knowing it’s powering the games!
We’re sure we’ve got a few white papers in us about our research and learnings of creating this platform and the first few games. For instance — code optimisation is a big deal! The first version of the Slot game’s Smart Contract guzzled 1.7 million gas but after a few rewrites we were down to less than 1/10th of that. There’s certainly an art and skill to writing optimised Smart Contracts that use as little gas as possible and the methods to achieve this are not well known. We’re happy to share how we did it with the wider developer community because the techniques are applicable to many real-time applications.
We also learned a lot about Randomness and how to do it efficiently. Generating responsive random numbers is one of the hardest problems to solve and is an integral part of the platform. We need them fast enough so as not to slow the player down. The games have to run at the player’s desired speed — sometimes every second or two per game — and not be waiting around for Oracles and Blockchains to come back with some entropy. The production RNG we’ve developed is super fast and yet still provably fair on-chain. It will also scale well when we have large numbers of users, and should also work fine when we’ve switched to Proof of Stake.
(Note: for those reading this after April 2017, this blog is a historical document, and this RNG block-hash method was used by us early in 2017. It has since been superseded by our much more advanced Fate Channel technology that delivers fast, robust and extremely flexible RNGs that are low gas cost and more advanced than other RNG methods like oracles or blockhashes etc)
One thing we learned is that the way we previously utilised random numbers in this slot game (coming from the blockchain’s block-hash) was fine for the prototype but wasn’t suited to the final production environment. It suffers limitations that could theoretically allow a miner to cheat (but crucially not ‘the house’). Miners could evaluate the smart contract to see if they’ve lost the game and then censor their losing bet transaction but allow it through if they won). Some existing smart contract based games are aware of this issue and have had to keep bet size low to de-risk it from miner attacks. So we’ve been developing cool new random number generation techniques and have a few new methods that we’re working on that are every bit as fast yet don’t allow miners (nor anyone else) to cheat. We’re playing with all the cool toys right now. RNGs, Oracles and especially State channels. Our CTO (Jeremy) likes to call them ‘Fate Channels’ 😉 The new RNG state channel system will be part of the platform and enabled for all games before launch — but for this prototype demonstration we’re still using the older block-hash method which is fine for now (and as far as we know, no miners are currently cheating). We had to build our own RNG fate/state channels because Raiden doesn’t yet support them and doesn’t seem to have a schedule of when it will, and is focussed on sending tokens first.
In this prototype demonstration we’re showing a short 2-min YouTube video recorded directly from my Mac running Chrome with Metamask. The games of course run in any Ethereum compatible browser on any device… like Mist, Metamask, Parity and also the mobile browsers like Status (tested), Token and Leth. We expect to increase support for other browsers before launch to cover the widest range of platforms possible.
In the very near future we plan to open up the alpha testing phase so everyone can have a play and let us know what they think… and we’ll be providing bug bounties and will start the professional audits of the first games very soon.
We’ve grown our development team from humble beginnings and are now ten people — funded by angel technology investors. The company is headquartered in Malta due to its friendliness to gaming development with offices in Camden Market (a cool part of central London) and are recruiting team members actively so if you know someone or are someone who might have the development skills and desire to join us — do make contact and let us know how you’d like to help. In due course we’ll need marketing and community liaison people too.
Most of the founder members of our team are experienced games developers (decades of creating hit games) and have also been involved in the creation of online casino and online poker games in our former work-lives. Some of us have also been licensed gaming key persons including having been regulated in several European jurisdictions to develop and operate online gaming. We have previously been investigated and authorised as ‘fit and proper’ persons as defined by several gaming jurisdictions requirements where they perform Due Diligence on you personally before allowing you to become a key person in a gaming operation. As Better Gaming, we are NOT expecting to be able to take our existing gaming licenses and authorisations with us into the new venture as smart contract based gaming is very ‘bleeding edge’ and it’s so new that we don’t expect regulators to fully grasp nor appreciate the implications overnight and there will need to be lots of discussion and negotiation before existing gaming jurisdictions license such activity. However we believe our experience of knowing how to develop and operate games legally and fairly in the past will be helpful to us and differentiate us from less experienced teams.
We’ve built these games together with the platform to run them. We did it this way around because we felt that we’d learn far more creating the games at the same time as building the platform, instead of building a platform first and then trying to shoehorn games onto it (and risk discovering the platform might not be capable). We think this method gets us a better platform, sooner… and then we can let other game developers have access to a proven and bedded in platform that works and can deliver realtime games and all associated services rather than a theoretical platform that might not. We also get to set the quality bar really high for the games so that other developers can see the level we expect to be on the platform.
We’re playing to our strengths of being Game Developers first. We hopefully know how to do that better than most.
1. This first prototype game we’re previewing is nearly finished but not quite. It serves as a demonstration that its possible to create server-less decentralised real-time games utilising Ethereum Smart Contracts and DApps. The three F’s, Fun, Fast and Fair.
2. We’re games developers, not operators. We’re finalising our ‘go to market’ strategy for later this year which will involve licensing the games to operators.
We’d love to hear your feedback. What we can do better? — Let us know what you think please, [email protected]
(Note, this blog was written in April 2017 and mentioned research work (relating to aspects such as Fate Channels) that was on-going at the time. Our advanced State Channel technology has now come to fruition and is an integral part of the FunFair platform technology. For a more up to-date-view of where we are, please see our Roadmap or play our Showcase games)