One of the things I like most about Counterparty tokens is apart from acting as an asset or coin or a collectable they can also act as game items.

An example is Spells of Genesis which I am sure you have heard of.

Spells of Genesis cards can be used as Game items in the game as well as contactables outside of the game.

Spells of Genesis and Rarepepe have a huge and passionate userbase, and as their items are Counterparty tokens on the Bitcoin blockchain anybody can use them in their own project with out permission.

For example, I make an game and I want to attract SoG and Rarepepe users, I can just add SoG and Rarepepe cards as game items.

In this article I will show how it can simply be done in Unity right now for Android, iOS and soon for PC. Sample application can be found here

From here it is a little technical and an understanding of Unity, iOS or Android dev will be needed. However you can refer to the sample application and the code is very minimal.

Lets take the following example. I have a simple game in which characters battle.

A popular SoG card is SARUTOBICARD and a popular Rarepepe is SARUTOBIPEPE.

I need to do 4 things

1.) Let the user link their coutnerparty wallet which holds the cards

2.) Prove that the user owns that wallet and isn’t using somebody elses address

3.) Read the balance to check the SARUTOBICARD and SARUTOBIPEPE exist on that address

4.) If they exist unlock the Sarutobi and Sarutobi pepe character in the game.

Setup

You can download the following sample project for Unity here

The project is bare bones and simple but lets you link to the users IndieSquare wallet or Book of Orbs wallet, verifies by sign message and loads the balance displaying it on the screen.

If you are not familiar with IndieSquare or Book of Orbs they are Counterparty wallets which lets you store bitcoin and Coutnerparty tokens/assets.

All of the code of interest is located in Scripts/GetAddress.cs

1.) Link the wallet

First we generate a random message and open the IndieSqaure or Book of Orbs app requesting that it returns the users address and signs the message we provided with the private key of the address. With this Signature we can prove that the user does in fact own the address.