I am designing the business network and I am implementing the logic.js for the network on hyperledger composer bluemix, I want to create an asset through a transaction in the logic.js file how to do that please? and I have another problem which is how to check a random number is not equal an old or active asset attribute in the transaction registry, I am creating a voucher consumption transaction and model.cto
asset Voucher identified by serial {
o String serial
o String Code //new code generated for every new consumption transaction
o DateTime creationDate
o Double amount
o Typev type
o Integer activated
}
enum Typev {
o paperVoucher
o giftVoucher
}
logic.js part of code:
do{
var min=1;
var max=999999;
var random = Math.floor(Math.random() * (+max - +min)) + +min;
}while (random!=//old serials or active serials); //missing random test with the old serials
For your first part of the question, refer to Asset Creation through Transaction in Hyperledger Composer
For your second part Check out Historian https://hyperledger.github.io/composer/latest/business-network/historian