3 回答

TA贡献1786条经验 获得超11个赞
也许你忘记了@Default装饰器
@Contract(name = "MyContract",
info = @Info(
title = "My Contract",
description = "",
version = "0.0.1"
)
)
@Default
public class MyContract implements ContractInterface {

TA贡献1830条经验 获得超9个赞
调用了未定义的合约方法
在代码的前几行。这意味着您传递给调用的函数不存在于链码中,您可以检查链码并查看 initLedger 是否存在?或者是否存在任何拼写错误。希望这是有用的。

TA贡献2011条经验 获得超2个赞
如果您在实例化链码时遇到此问题,则可以使用您的自定义实现覆盖ContractInterface中给出的以下方法。
/**
* Invoked for any transaction that does not exist.
*
* This will throw an exception. If you wish to alter the exception thrown or
* if you wish to consider requests for transactions that don't exist as not an
* error, subclass this method.
*
* @param ctx the context as created by {@link #createContext(ChaincodeStub)}.
*/
default void unknownTransaction(Context ctx) {
throw new ChaincodeException("Undefined contract method called");
}
否则,如果在调用现有事务时出现问题,则确保注释@Transaction() 存在于事务方法中。
添加回答
举报