3 回答

TA貢獻1786條經(jīng)驗 獲得超11個贊
也許你忘記了@Default裝飾器
@Contract(name = "MyContract",
info = @Info(
title = "My Contract",
description = "",
version = "0.0.1"
)
)
@Default
public class MyContract implements ContractInterface {

TA貢獻1830條經(jīng)驗 獲得超9個贊
調(diào)用了未定義的合約方法
在代碼的前幾行。這意味著您傳遞給調(diào)用的函數(shù)不存在于鏈碼中,您可以檢查鏈碼并查看 initLedger 是否存在?或者是否存在任何拼寫錯誤。希望這是有用的。

TA貢獻2011條經(jīng)驗 獲得超2個贊
如果您在實例化鏈碼時遇到此問題,則可以使用您的自定義實現(xiàn)覆蓋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");
}
否則,如果在調(diào)用現(xiàn)有事務(wù)時出現(xiàn)問題,則確保注釋@Transaction() 存在于事務(wù)方法中。
添加回答
舉報