Building a Kin-powered app with Unity, Part 5

Will Gikandi
Aug 11, 2019 · 5 min read

Create a server to onboard accounts and whitelist transactions

In the last tutorial, we learned about the necessity of onboarding an account on the blockchain through a trusted server.

In this tutorial, we will cover how to create a server we can use to onboard accounts.

For this tutorial, we will use Node.js and Heroku’s free servers. If you have never used either, don’t worry! This step by step will guide you all the way. Feel free to skip some steps if you are familiar with Heroku and Node.js.

NOTE: We will also look at other alternatives to Node in later tutorials.

Step 1: Create an account on Heroku

Go to Heroku and sign up for their free account.

Step 2: Download Heroku’s Command Line Interface (CLI)

Get Heroku’s CLI from here and install it.

Step 3: Go to your Heroku Dashboard and create a new app

Access the dashboard here. Give it an available name and click create.

Copy your app name above, as we will use it in some steps below.

Step 4: Get your server’s URL

Before you close the window, click on settings and scroll down to get the URL of your new server.

Modify the code in Tutorial so that it has your server’s URL.

void Start(){string url = "";kinWrapper = GameObject.Find("KinWrapper").GetComponent<KinWrapper>();kinWrapper.Initialize(ListenKin, url);}

The wrapper now knows the location of your server.

Step 5: Create a local folder

Open your My Documents folder, and create an empty folder called “kin-server”

Enter this folder, and copy the address.

Step 6: Access the CLI

Open Windows Power Shell and type:

> cd "C:\Path\to\your\Documents\kin-server"

Once in your folder, type the following lines individually

> heroku login
> git init
> heroku git:remote -a your-app-name

Once you have run these commands, you have connected your local folder to Heroku, and publishing should be a cinch!

Step 7: Install the server code on your local folder

In your console, type:

git pull

You just used git to pull source code from a repository, and we will now change it for our purposes, before pushing it to our free server.

You should get a read-out similar to this

The server code is now sitting on your local computer. You will now need to create a Kin account on the blockchain for your private server and give the server its private key.

Remember in the same way the client has a public address and private key, your sever also needs one to send transactions to all of its clients.

Step 8: Create an address and private key for your sever

Just like in the previous tutorial, access the Kin Laboratory and create a keypair and onboard it with test Kin. (For now, we will use the Test environment, which uses free Kin. When ready for production, we can re-use the same address and fund it with actual Kin.)

Step 9: Transfer your private key to your server.

Open server.js in your local server folder, and modify the variable seed, replacing it with your private key.

For security, the seed should be stored in an environment variable. However to keep things simple, for now, we will use it from within the code.

Step 10: Transfer the server’s public key to your client.

To allow the client to send Kin to the server, it needs to know the public address. Copy this public address, and paste it into your tutorial script.

void Start(){    string url = "";    string serverAddress = "  GAKUXKB3SXSJGBVBPR3YILATXP5NDUHOUK4QISHRWSO7WU6K6ILHY2SR";    kinWrapper = GameObject.Find("KinWrapper").GetComponent<KinWrapper>();    kinWrapper.Initialize(ListenKin, url, serverAddress);}

Your client is now fully equipped to talk to the server.

Step 11: Publish your server onto Heroku

In your CLI, type the following individually:

git add .
git commit -am "first commit"
git push heroku master

The above commands tell git to record all the files we have added to the folder, mark that as a “check point,” and upload it to Heroku.

To test that your server is running, you can paste your server’s URL to a browser, and you should get a response:

This is just your server responding to the client, stating it has not received any get or post variables to process.


So far, we have a client with:
1. The Kin SDK
2. A private key/public address
3. The server’s URL to make requests to the server
4. The server’s public address to send Kin to the server

We also have a server:
1. With a private key/public address
2. That can handle any requests from any number of clients

Before we begin communicating to the server, we need to understand what is happening “under the hood”, so to speak. In the next tutorial, we will briefly look at the server’s code to understand its functions.

This will enable you to modify it to your needs, beef up security, and even use your favorite language! (Node.js, Python, PHP, etc.)

After that, we will be ready to code! In the next tutorial, we will dive deeper into how the server works.

Kin Blog

Kin is money. Earn, spend, and transfer value across an ecosystem of apps and services. Get paid for developing engaging user experiences with Kin.

Will Gikandi

Written by

Kin Blog

Kin Blog

Kin is money. Earn, spend, and transfer value across an ecosystem of apps and services. Get paid for developing engaging user experiences with Kin.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade