Image for post
Image for post

Basic Deck Creation with PeerAssets [Tutorial]

Oct 29, 2018 · 4 min read

Today we will be working through the basics of spawning a PeerAssets Deck with 100 Cards. You can find a full README of the capabilities of PeerAssets here:

For our example, we’ll be making a tipping bot that sends TestNet Peercoin to another address.

First, make sure you have the most up-to-date version of pacli downloaded for your relevant OS. You can get it from here:

Note: For those on windows, make sure after you extract everything, open CMD to use the commands. Easiest way to open CMD is to type “CMD” in the address bar, opening it to the directory. CMD guide can be found here:

You can find your address by using

pacli address show
Image for post
Image for post

This will pull your public address. You can check your balance with pacli address balance. This will be zero until you have some testnet Peercoins. You can get testnet Peercoins from 1. Just paste the address we got above and wait 5–10 minutes for the transaction to be confirmed. You can check your balance until they appear. We need a small amount of Peercoin because PeerAssets stores a small amount of information in block information which is otherwise unused, meaning PeerAssets can be chain agnostic, or be used with any chain.

These rules are called “deck issue modes” and are set into the deck spawn metainfo, which is encoded in a protobuf message and inserted into the OP_RETURN field of a Peercoin transaction. ( 1)

Think of PeerAssets like a hitchhiker, with Peercoin being a truck driving by. There is an open and empty seat that no one is using and PeerAssets can attach deck data to this slot to allow it to carry on its way. Obviously the truck is a part of the blockchain and the underlying mechanisms are more complex, but hopefully this metaphor serves its purpose.

Image for post
Image for post

You can see that now it says my balance is 99.82 testnet Peercoin.

So now we have some testnet Peercoin and we can make a deck with some cards which is the fun part. Since we are building a tipping bot, these will represent an arbitrary point system like karma or upvotes. This concept could be expanded in a myriad of ways to support any type of system where assets could be tracked. The base command for this is pacli deck and it needs some arguments so it knows what exactly we are doing.

For this, we will be using “–name”, “–number_of_decimals”, and “–issue_mode”. The name flag will be the readable name for the deck, which in this case will be “PeerCookies” giving us “–name “PeerCookies” (You can name yours whatever). Number of decimals tells us how the cards can be divided. We will be using “4” which means each card can be divided from .0001 to .9999. If you chose “0”, each card would have to be sent as a whole number like “1, 2, 16”. Issue mode determines the rules the deck will follow in terms of card creation and how the deck will function. You can read more about that here: For this tutorial we will be using MULTI since it will allow me to generate tips as needed. The value for this will be “4”, giving us, “–issue_mode 4”. I found the SUBSCRIPTION mode interesting and would like to look into using such a system to manage indicator access in the future.

Our final command is:

pacli deck spawn --name "PeerCookies" --number_of_decimals 4 --issue_mode 4 --sign --send
Image for post
Image for post

We include –sign and –send to send the deck for confirmation on the testnet, solidifying it into the chain’s history. Once we hit enter, we are returned a hash which includes my deck ID. We will use this Deck ID shortly. In my case it is: 310403a934bacd3fabb2bf4bb83cb0429c7d25907e623815ef494d62fa042a67. It is visible here:

Well, so now we have a deck, but we don’t have any use unless we include others. Since Peerchemist provides so much value, I decided to send him 1 “PeerCookie”. You can do this by using:

pacli card issue 310403a934bacd3fabb2bf4bb83cb0429c7d25907e623815ef494d62fa042a67 [mstyWZRR9VyYpRRyZ4Fd5Bvcua5mPujj3k] [100] --sign --send

In simpler terms, we want to issue a card from a deck and we want to send it to another address (in this case: mstyWZRR9VyYpRRyZ4Fd5Bvcua5mPujj3k or Peerchemist) This sent 100 cards or cookies to him and it returned a txid if you wanted to track it on the chain.

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store