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() 存在于事務方法中。
添加回答
舉報