亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

未能調用鏈代碼名稱:“lscc”,錯誤:事務返回失敗:調用了未定義的合約方法

未能調用鏈代碼名稱:“lscc”,錯誤:事務返回失敗:調用了未定義的合約方法

qq_遁去的一_1 2023-05-17 15:00:42
我正在嘗試從 fabric-samples 安裝 facar 的 java 鏈代碼,但出現錯誤。https://github.com/hyperledger/fabric-samples/tree/release-1.4/chaincode/fabcar/java在鏈碼上方,我正在嘗試并在鏈碼實例化期間出現錯誤有人可以幫助我嗎,非常感謝并提前致謝。我正在使用基本網絡文件夾和下面的腳本來創建和安裝網絡,實例化和調用鏈代碼。#!/bin/bash## Copyright IBM Corp All Rights Reserved## SPDX-License-Identifier: Apache-2.0## Exit on first error, print all commands.set -ev# don't rewrite paths for Windows Git Bash usersexport MSYS_NO_PATHCONV=1docker-compose -f docker-compose.yml downdocker-compose -f docker-compose.yml up -d ca.example.com orderer.example.com peer0.org1.example.com couchdbdocker ps -a# wait for Hyperledger Fabric to start# incase of errors when running later commands, issue export FABRIC_START_TIMEOUT=<larger number>export FABRIC_START_TIMEOUT=10#echo ${FABRIC_START_TIMEOUT}sleep ${FABRIC_START_TIMEOUT}# Create the channeldocker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel create -o orderer.example.com:7050 -c mychannel -f /etc/hyperledger/configtx/channel.tx# Join peer0.org1.example.com to the channel.docker exec -e "CORE_PEER_LOCALMSPID=Org1MSP" -e "CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/msp/users/[email protected]/msp" peer0.org1.example.com peer channel join -b mychannel.blockdocker-compose -f docker-compose.yml up -d clisleep 5
查看完整描述

3 回答

?
Qyouu

TA貢獻1786條經驗 獲得超11個贊

也許你忘記了@Default裝飾器


@Contract(name = "MyContract",

        info = @Info(

                title = "My Contract",

                description = "",

                version = "0.0.1"

        )

)

@Default

public class MyContract implements ContractInterface {


查看完整回答
反對 回復 2023-05-17
?
慕標琳琳

TA貢獻1830條經驗 獲得超9個贊

調用了未定義的合約方法

在代碼的前幾行。這意味著您傳遞給調用的函數不存在于鏈碼中,您可以檢查鏈碼并查看 initLedger 是否存在?或者是否存在任何拼寫錯誤。希望這是有用的。


查看完整回答
反對 回復 2023-05-17
?
森林海

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() 存在于事務方法中。


查看完整回答
反對 回復 2023-05-17
  • 3 回答
  • 0 關注
  • 313 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號