我在使我的交易在Hyperledger作曲家游乐场上工作时遇到问题。
我的script.js文件中有一个名为CastVote的函数,而模型文件中有一个名为CastVote的事务。每当我尝试提交事务时,似乎都无法在我的脚本文件中找到CastVote函数。我收到以下错误:
下面是我的代码:
模型文件:
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
}
脚本文件:
/**
*
* @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);
})
}
您输入的transaction
拼写有误
* @transacation
应该的时候
* @transaction