Interpreting transaction type

+1 vote
Hi,

Suppose I start reading all blocks and fetch transactions which are part of it. How do I make a distinction betwen transaction type like this is a permission grant transaction, or an asset creation transaction or asset transfer or a coinbase transaction? What is the simple way of doing this?
asked Apr 25, 2016 by amanc

1 Answer

0 votes

The best thing to do is pass the raw hexadecimal transaction to decoderawtransaction which gives you the full details of what happened in it. You can also call getrawtransaction with verbose=1 to do this from a txid.

answered Apr 26, 2016 by MultiChain
Yes I am getting the details of the transaction either using getrawtransaction or decoderawtransaction api but how do I distinguish the type - whether it is a permission grant transaction or an asset creation transaction or asset transfer or a coinbase transaction?
There is no single "type" of transaction since it's possible (at least in theory) for one transaction to assign a permission, issue an asset, and transfer another asset. simultaneously. Instead you need to look for fields in the output from these APIs to see if there is an issuance / permission grant / asset transfer in the transaction.
So how do I make out that from the transaction output?
For permissions assignments, look for the "permissions" structure in one of the "vout" elements. The presence of assets in an output is also shown in an "assets" structure in the corresponding "vout" element. It's not yet easy to distinguish an asset transfer from an issuance but you can look at the prefix of the hex string that comes before OP_DROP in the "asm" of each output's "scriptPubKey" and compare it to the documentation on http://www.multichain.com/developers/native-assets/ - or wait for the next alpha which will provide information to distinguish these two cases in an easier-to-use form.
The latest alpha 20, just released, gives more information in decoderawtransaction, including differentiating between new assets issued and assets transferred from previous issues.
Ok, will have a look. Thanks.
...