The first step on our journey to democratize the blockchain is building our mobile strategy game, CryptoWars, that will fully run on the Ethereum blockchain — huge tech challenge considering there’s not much development done on this space.

Let’s get to it. To connect with the Ethereum network (both main and testnet) we’ll use the Nethereum .net cross platform integration library. With Nethereum we’ll be able to create and import Ethereum wallets, create and use smart contracts and access all information available on the Ethereum blockchain.

To do this, we need the following:

1: Unity

2: Nethereum version: (2.0.0)

3: Infura or any other service that can act as our node

4: Coffee and some good jams

Let’s start by creating a new project with Unity:

Now let’s import the Nethereum libraries:

Just drag and drop Nethereum.Unity into the Assets folder.

As a really simple test, we will check the balance of an address and print it in the console tab. In order to do this, we’ll have to create a script, import a few more libraries, and choose a network to connect to, in this case: Kovan testnetthrough Infura.

Now we need to create a C# Script named Account, open it using MonoDevelop and insert this code.

Paste the code, hit save and go back to Unity.

You can drag & drop the script from Assets to the Inspector’s GameObject.

Now let’s run our game and see how it goes… :)

ETH Balance: 4.253861012499842992 (In the console tab!)

Congrats! You’ve completed your first cross-platform interaction in the form of a Debug.log! Now let’s do something a bit more interesting: Let’s create a wallet.

Paste this code into Account.cs and press play (It’s gonna take a while)

When it’s done loading we’ll be able to see the address of our new account and the encrypted JSON that contains our secret key. We will also see the balance of our newly created account (which is 0 ETH, obviously)

After a few seconds you’ll be able to check the logs and see your newly created account.

And that’s all for now, folks. In part 2 we will show you how to interact with a contract from Unity3D!

View original content here: Medium.com

Experimental