Building smart contracts for UK games development

Sam Davies

Sam Davies is Lead Technologist at Digital Catapult

Sam Davies, Lead Technologist at Digital Catapult, reviews some of the technical details of the system Digital Catapult built as part of the UK Games Fund smart contracts project. Read on to find out more about our work with UK Games Fund and smart contracts.

The recent work for our UK Games Fund smart contracts prototype was built with two main purposes in mind: To create a testbed environment so that the UK Games Fund Tranzfuser could trial out developing a game using Smart Contracts and create a framework environment for future development. We also wanted to boost our in house capability in creating and designing smart contracts so we can look at other applications such as IoT.

The prototype enables teams to register and identify equity, ownership and some business rules to create a game

The prototype enables teams to register and identify equity, ownership and some business rules to create a game

The initial prototype had a relatively simple goal; to enable teams to register and identify equity, ownership and some business rules to create a game. At this early stage we were not interested in any value flow throughout the system (e.g. through payments to members) or in allowing for changes to be made. Both these parts are currently in development for our next release.

Digital Catapult
used the Ethereum blockchain for this prototype. Giving the benefits of a relatively stable release (Homestead), a language for designing and implementing smart contracts (Solidity), along with support for platform integration. There are images available on the major cloud platforms, though in this instance we chose to host our own network. We set up a private/permissioned network using Ethereum; we control who is allowed to join as a node and who is allowed to transact on the network. As this is an unproven prototype we wanted to retain full control and so this offered those benefits. We were also able to set the mining complexity making it easier and quicker to mine blocks; we were able to use free tier AWS machines for mining helping keep costs low. Using Ethereum transaction costs meant we didn’t have to spend any ether as Gas Price; important to us when we’re making multiple dummy transactions.

The smart contract uses Ethereum blockchain technology,

The smart contracts developed were relatively straight forward. Once a user has an Ethereum address on our blockchain, they could join a team.  Upon joining a team, the members could decide upon their game name, the distribution of Tals which define how much equity they have and their voting rights, along with rules the team must adhere to. A user could also change ownership of their Tals (e.g. re-sell them or give them away) and any un-issued Tals could be issued at a later date.

To help prevent misuse of the system we took advantage of the contract inheritance which is feature of Solidity. This allows us to bring in functions from one contract to another. The UK Games Fund had been set up as a dispute resolution service in this system; if there were any disagreements all team members agreed (via a smart contract) that the UK Games Fund would act as an arbitrator.  As such, we were able to give the UK Games Fund control over the issuance and ownership transfer of Tals; if a Tal had been transferred erroneously or maliciously the UK Games Fund had the power to undo that transaction. It was decided that Tals are non-fungible assets and so this approach allowed for control.

The project enabled users to test smart contracts via distributed ledger

The project enabled users to test smart contracts via distributed ledger

We published these contracts, along with the contract addresses and application binary interface. Thus, anyone who wanted to could now set up a game development team just using the blockchain platform (provided they were allowed to connect).  However, as many of the Tranzfuser participants hadn’t heard of smart contracts let alone interact with them, we also built a web based front end for them to use. There are some really useful libraries to interface between standard languages and Solidity smart contracts.  As we were using Javascript and Node.js to create the front end server, we used the Web3.js libraries which allowed our server to invoke and interact with contracts directly.  With this, we created a set of Rest APIs which provided the same functionality as the contract interfaces.  Using React.js we also created a user interface, allowing a set of forms for users to use to create their games.

If you’d like any more info on the system, we built or access please do get in touch (email info@digicatapult.org.uk). In building this initial prototype we learnt a lot and are so using that to build an enhanced version.

Sam Davies is Lead Technologist at Digital Catapult. You can follow him on twitter @Sam_D_ on Don’t forget to follow us too @DigiCatapult.

You can find out more about our work with UK Games fund and Smart Contracts here or to find out more about our work with blockchain and how you can get involved by attending our Blockchain Meetup

Leave a comment

Share