corda:java.lang.illegalargumentexception:此attachmentwithcontext未正确初始化

vlurs2pr  于 2021-07-03  发布在  Java
关注(0)|答案(1)|浏览(336)

在我们的项目中,我们有一个非失效令牌状态和非失效令牌契约的定制实现。我们正在使用下面的代码发布我们的自定义不可替换令牌。

Party notary = NotaryUtilitiesKt.getPreferredNotary(getServiceHub(),NotaryUtilitiesKt.firstNotary());
        TransactionBuilder transactionBuilder = new TransactionBuilder(notary);
        IssueTokensUtilitiesKt.addIssueTokens(transactionBuilder, tokensToIssue);
        FlowUtilitiesKt.addTokenTypeJar(tokensToIssue, transactionBuilder);

尝试将上述获得的事务生成器转换为有线事务时( builder.toWireTransaction(serviceHub); )下面的堆栈跟踪出现错误。

java.lang.IllegalArgumentException: This AttachmentWithContext was not initialised properly. Please ensure all Corda contracts extending existing Corda contracts also implement the Contract base class.
    at net.corda.core.internal.AttachmentWithContext.<init>(AttachmentWithContext.kt:18)
    at net.corda.core.transactions.TransactionBuilder.handleContract(TransactionBuilder.kt:487)
    at net.corda.core.transactions.TransactionBuilder.selectContractAttachmentsAndOutputStateConstraints(TransactionBuilder.kt:359)
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext(TransactionBuilder.kt:159)
    at net.corda.core.transactions.TransactionBuilder.toWireTransactionWithContext$core(TransactionBuilder.kt:146)
    at net.corda.core.transactions.TransactionBuilder.toWireTransaction(TransactionBuilder.kt:140)
qyswt5oh

qyswt5oh1#

正如alesandro所说,这个错误似乎确实指向了合同类问题。
请确保所有扩展现有corda合同的corda合同也实现了合同基类。
我将再次检查您的contract类是否正确地实现了contract。像这样:

class IOUContract : Contract {
companion object {
    @JvmStatic
    val IOU_CONTRACT_ID = "net.corda.training.contracts.IOUContract"
}

资料来源:https://github.com/corda/samples-kotlin/blob/master/advanced/obligation-cordapp/contracts-kotlin/src/main/kotlin/net/corda/training/contracts/ioucontract.kt
祝你好运!

相关问题