March 2019
Intermediate to advanced
636 pages
27h 50m
English
For the purpose of our tests, we will keep the new transaction relatively simple: our transaction will merge two assets into one, adding their value in the process.
To declare the new transaction, we will edit the model file and add this new declaration:
transaction MergeAssets {--> Asset mergeFrom--> Asset mergeTo}
With the definition created, let's add the logic in the /lib/logic.js file:
/** * Sample transaction * @param {org.example.biznet.MergeAssets} tx * @transaction */function onMergeAssets(tx) { var assetRegistry; var mergeFromAsset = tx.mergeFrom; var mergeToAsset = tx.mergeTo; mergeToAsset.value += tx.mergeFrom.value; return getAssetRegistry('org.example.biznet.SampleAsset') .then(function(ar) { assetRegistry ...
Read now
Unlock full access