I/O Coin Unity package
Download v1.0.1
Changes v1.0.0 -> 1.0.1
Text changes, default wallet is now 'iocoin-games' and replaced an obsolete WWW function.
With the I/O Coin package for Unity 3D you get the power of a stable, reliable and working blockchain in your games.
The I/O Coin package for Unity 3D is suitable for Windows and OSX games.
About Switching Brains
https://switchingbrains.com/
Switching Brains is founded in 2009 by Dennis van Koningsbruggen. Currently developing in Unity 3D.
About I/O Coin
https://www.iocoin.io/
I/O coin is launched in 2014 and still in development by a group of experts on blockchain security and cryptocurrency. IOC had a fair launch, which means that there was no Initial Public Coin Offering (IPCO), giveaway, or pre-mining done for IOC. Thus, the coin distribution for I/O Coin is much more transparent and fair than many other altcoins. This means there is no danger of the developer, or any single user, secretly hoarding a significant number of coins.
Key features of the I/O Coin blockchain:
About Unity 3D
https://unity3d.com/
Unity 3D is the world's leading real-time engine. Unity is used to create half of the world's games. Flexible real-time tools offer incredible possibilities for game developers, and creators across industries and applications.
The I/O Coin package for Unity 3D is made available under terms to make clear that the package is offered "as-is", without warranty, and disclaiming liability for ANY damages (so that's including loss of coins) resulting from using the package.
Import this plugin in your Unity project. Check Importing Asset packages from the Unity 3D docs for instructions. Before you can use this install the following FREE dependencies with it:
I/O Coin Wallet
Available on the official I/O Coin website
You need a local I/O Coin wallet, with some balance, installed on your computer. Follow the installation guide on the website.
Thread Ninja - Multithread Coroutine
Available here in the Unity Asset Store
A simple script helps you write multithread coroutines. Import this in your project.
SimpleJSON
Available here
SimpleJSON is an easy to use JSON parser and builder. Download and unpack in your '\UnityProject\Assets' folder.
After installing the dependencies, the plugin is ready for use. There is a demo scene to show the workings and how to use some of the functions that are available.
Installation video
Using the plugin is fairly straight forward. Just drag the 'IOCoin' object from 'switching brains -> IOCoin -> assets -> meshes' in your first scene of your project. Why the first scene? Because once loaded, it is available through the whole project. You can get the package object in your own scripts like this:
public class Example : MonoBehaviour { IOCoin ioc; private void Start() { // This is the I/O Coin package object // The API and wallet are available through here ioc = (IOCoin)FindObjectOfType(typeof(IOCoin)); } }
There are some options on the object in the inspector for you to customise the I/O Coin plugin:
Wallet Dir | This is the directory from the official I/O Coin Html5 wallet you want to use. |
Auto Start | Auto starts the daemon if it is not allready running. If set to false, the daemon needs to be running in the background allready. |
UI Wallet Status | Link an UI Text component here to show wallet status on screen. |
The I/O Coin Wallet object
The wallet object is always available. The following data is available in the wallet:
variable | type | description |
---|---|---|
wallet.status.online | boolean | True if the I/O Coin daemon is running on the local machine. |
wallet.status.synced | boolean | True if the wallet is fully synced |
wallet.status.locked | boolean | True if the wallet is locked. For the users safety only unlockable in the official I/O Coin Html5 wallet by the user itself. |
wallet.status.code | int | Statuscode of the wallet |
wallet.status.message | string | Statusmessage matching the statuscode -1 Wallet offline, please start wallet. |
wallet.price.btc | float | The current price of 1 I/O Coin in Bitcoin value |
wallet.price.usd | float | The current price of 1 I/O Coin in US Dollar value |
wallet.price.eur | float | The current price of 1 I/O Coin in Euro value |
wallet.balance.ioc | float | Main I/O Coin wallet balance |
wallet.balance.btc | float | Main I/O Coin wallet balance in Bitcoin value |
wallet.balance.usd | float | Main I/O Coin wallet balance in US Dollar value |
wallet.balance.eur | float | Main I/O Coin wallet balance in Euro value |
wallet.balance.min | float | Minimum balance in I/O Coin required to work |
wallet.block | int | Wallets last synced block |
wallet.blocksFromPeers | int | Highest available block in the chain |
wallet.payment.inProgress | boolean | True if payment is in progress |
wallet.payment.paid | boolean | True if the last payment is successfull |
wallet.payment.response | string | Response of the last transaction, if succesfull this is the transaction id of the last payment |
wallet.payment.error | boolean | True if an error occured during transaction |
wallet.payment.message | string | Message of the last transaction |
wallet.autostart | boolean | True if the wallet/daemon autostarts if not available |
Functions
There are a couple of function available:
Prepare Payment
Set the target I/O Coin wallet address and amount of I/O Coin for the next transaction.
ioc.wallet.PreparePayment("ifURRvG6asxQJauo9G8gGEfqnbYKzq3UYK", 10); // Prepare payment for 10 I/O Coin to the address.
Insert Coin
Use this to let the player pay before play. Like inserting a coin in an arcade machine.
ioc.wallet.InsertCoin(); // Start payment!
Because of the async nature of the package you can check payment like this:
void Update () { // Check if coin has been inserted and 'do something' if (ioc.wallet.payment.paid == true) { ioc.wallet.ResetPaymentStatus(); // Start your next scene (or whatever) here :) } }
Send To Address
Send an amount of I/O Coin to an I/O Coin wallet address (set by the prepare payment function).
ioc.SendToAddress(); // Start payment!
You can check payment like this:
void Update () { // Check if transaction is a success and 'do something' if (ioc.wallet.payment.paid == true) { ioc.wallet.ResetPaymentStatus(); // Do whatever here :) } }
Reset Payment Status
After a payment is done and did your stuff with the transaction. Reset the status to get ready for a next payment.
ioc.ResetPaymentStatus();
User Interaction
If you attach the I/O Coin game object to your UI component there are a couple of functions available:
InsertCoin() | Use this to let the player pay before play. Like inserting a coin in an arcade machine. You can check payment in the same way as the function. |
SendToAddress() | Send an amount of I/O Coin to an I/O Coin wallet address. You can check payment in the same way as the function. |
For each transaction you pay a small fee. Paid fees are redistributed as a reward for stakers. Check https://www.iocoin.io/ for more info about fees and 'proof of stake'. At the time of writing the fees are:
Action | Transaction Fee (I/O Coin) | |
---|---|---|
InsertCoin() | 0.01 | |
SendToAddress() | 0.01 |
So you need some help or have some questons? No problem, please use the following Telegram channels:
I/O Coin main Telegram channel
https://t.me/iodigital
This is the official main I/O Coin Telegram channel.
I/O Coin wallet support Telegram channel
https://t.me/iodigitalsupport
Problems with your wallet? Go here. There is a great community available to help.
I/O Coin developers Telegram channel
https://t.me/iodigitaldevelopers
This is also the place for questions about this package.
If you like this project, please help make ongoing development and improvements of this project and future Switching Brains projects possible.
The Switching Brains Funds I/O Coin address is:
ifURRvG6asxQJauo9G8gGEfqnbYKzq3UYK