合约validation失败,在corda Hello World pt 2

我正在使用kotlin在corda tutorial pt 2中学习这个教程 。 每次我尝试使用下面的命令通过PartyA中的CRaSH shell启动一个新的流程:

start IOUFlow iouValue: 30, otherParty: "C=US, L=New York, O=PartyB" 

我收到合同validation失败:

 Done Contract verification failed: List has more than one element., contract: com.template.IOUContract@7c109db7, transaction: D08920023D788F80F289527BD9C27BCD54B7DAC6C53866BFA7B90B23E0E4749B 

IOUFlow类:

 @InitiatingFlow @StartableByRPC class IOUFlow(val iouValue: Int, val otherParty: Party) : FlowLogic() { override val progressTracker = ProgressTracker() @Suspendable override fun call() { val notary = serviceHub.networkMapCache.notaryIdentities[0] val outputState = IOUState(iouValue, ourIdentity, otherParty) val outputContract = IOUContract::class.jvmName val outputContractAndState = StateAndContract(outputState, outputContract) val cmd = Command(IOUContract.Create(), listOf(ourIdentity.owningKey, otherParty.owningKey)) val txBuilder = TransactionBuilder(notary = notary) .addOutputState(outputState, TEMPLATE_CONTRACT_ID) .addCommand(cmd) txBuilder.withItems(outputContractAndState, cmd) txBuilder.verify(serviceHub) val signedTx = serviceHub.signInitialTransaction(txBuilder) val otherpartySession = initiateFlow(otherParty) val fullySignedTx = subFlow(CollectSignaturesFlow(signedTx, listOf(otherpartySession), CollectSignaturesFlow.tracker())) subFlow(FinalityFlow(fullySignedTx)) } } 

我已经尝试修改App.kt来处理这个问题,但没有运气。 有谁知道问题是什么?

在此先感谢您的帮助。

问题是您要将命令和输出添加到事务两次:

 val txBuilder = TransactionBuilder(notary = notary) .addOutputState(outputState, TEMPLATE_CONTRACT_ID) .addCommand(cmd) txBuilder.withItems(outputContractAndState, cmd) 

这会导致合同validation失败,因为您有两个输出而不是一个输出。