I am having issues trying to get my transactions working on Hyperledger composer playground.
I have a function called CastVote in my script.js file and a transaction called CastVote in my model file. Whenever I try to submit a transaction, it seems it can not find the CastVote function in my script file. I'm getting the below error:
Below is my code:
Model File:
namespace org.example.tasweetx
asset Vote identified by voteID {
o String voteID
o String voterID
o String candidateID
}
participant Voter identified by voterID {
o String voterID
o String voterFirstName
o String voterLastName
o String voterEmail
o String voterEmiratesID
}
participant Candidate identified by candidateID {
o String candidateID
o String candidateFirstName
o String candidateLastName
o Integer voteCount
}
transaction CastVote {
--> Voter voter
--> Candidate candidate
}
Script File:
/**
*
* @param {org.example.tasweetx.CastVote} transacation Function to handle vote casting and incrementing candidate vote count
* @transacation
*/
function CastVote(transacation) {
if(voter.voted == false) {
voter.voted == true;
IncrementVoteCount(transacation)
return getAssetRegistry('org.example.tasweetx.Candidate')
.then(function (assetRegistry){
return assetRegistry.update(voteCount);
})
} else {
throw new Error('You have already voted!');
}
}
function IncrementVoteCount(transacation) {
candidate.voteCount += 1;
return getAssetRegistry('org.example.tasweetx.Candidate')
.then(function (assetRegistry) {
return assetRegistry.update(voteCount);
})
}
you spelt transaction
incorrectly, you have put
* @transacation
when it should be
* @transaction