...by Daniel Szego
quote
"On a long enough timeline we will all become Satoshi Nakamoto.."
Daniel Szego

Monday, October 8, 2018

Fabric composer tips and tricks - getting type of an asset


If you use inheritance of assets in fabric composer and want to implement a transaction that execution is dependent on the actual asset type, you can use the following convention. Supposing that you have inheriting assets, like:

asset Ancestor identified by assetId {
  o String assetId
}

asset Descendant extends Ancestor{
}

you can query the exact type and the namespace of the asset with the following code:

toState.$type
toState.$namespace