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: https://github.com/PeerAssets/pacli/blob/master/README.md
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: https://github.com/PeerAssets/pacli/
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: https://www.thewindowsclub.com/how-to-open-command-prompt-from-right-click-menu.
You can find your address by using:
pacli address show
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 https://faucet.peercoinexplorer.net/. 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. (https://medium.com/peercoin/peerassets-deck-issue-modes-c419f38f7800)
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.
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: https://medium.com/peercoin/peerassets-deck-issue-modes-c419f38f7800. 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
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: https://chainz.cryptoid.info/ppc-test/tx.dws?310403a934bacd3fabb2bf4bb83cb0429c7d25907e623815ef494d62fa042a67.htm
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]  --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.
EDIT: Changed Deck ID for reasons.