In the previous tutorial, we finally put everything together to earn and spend Kin in our app. In this tutorial, we will cover whitelisting transactions and switching to production.
By now, you have probably noticed that, even though your app is sending and requesting whole numbers in Kin, your balance is being charged a few units of Kin for each transaction.
To process free transactions, we need to get our server whitelisted and approved by the Kin foundation. Once whitelisted by Kin, your server can now whitelist individual transactions for your client. (We covered this in a previous tutorial.)
Moving to production and whitelisting
Step 1: Register for the Kin Developer Program
Register your app and server’s public address to the Kin Developer Program. The Kin Foundation will issue you with a 4 character Unique appId.
Step 2: Change your server and client variables (in the wrapper)
Change your initialization variables in the server and client to production, and to use your new appId.
Step 3: Change your wrapper to allow whitelisting
Whitelisting will only work after you have been authorized by the Kin Foundation. Whitelisting before being authorized will result in failed transactions.
Currently, your client builds a transaction locally before sending it directly to Kin’s blockchain. However, we will change the client so that, in order to send a zero-fee (whitelisted) transaction, it will do the following:
1. Build the transaction locally
2. Send it to the server to whitelist by signing it
3. Receive back a signed response from the server
4. Send the signed transaction to the blockchain for zero fees
To do this, we simply open the wrapper and comment out:
These steps will allow your transactions to be whitelisted.
Step 4: Fund your production address with real Kin
Finally, simply fund your production address with real Kin and your app is ready to launch!
You now have a client and server that handle earns and spends which you can call anywhere within your app. Now that we understand the basic steps to working with Kin, you will need to harden your server from potential hackers.
Hardening your server:
- Use environment variables for your private key
- Implement secure communication for your server (Credit: Luc Hendriks)
- Use hot and cold wallets as a final safety measure (Credit: Luc Hendriks)
With that, you have a fully working, secure client and server solution.