Hyperledger fabric 调用链码为“时出错”;参数数量不正确。期望6“;

Hyperledger fabric 调用链码为“时出错”;参数数量不正确。期望6“;,hyperledger-fabric,hyperledger,Hyperledger Fabric,Hyperledger,我试图调用chaincode函数,但出现错误“参数数量不正确。应为6” 我已经检查了我的链码,看它是否正常运行。我不明白为什么它会出错。因为函数中有正确数量的参数 链码函数 func (s *SmartContract) recordProduce(APIstub shim.ChaincodeStubInterface, args []string) sc.Response { if len(args) != 5 { return shim.Error("Incorre

我试图调用chaincode函数,但出现错误“参数数量不正确。应为6”

我已经检查了我的链码,看它是否正常运行。我不明白为什么它会出错。因为函数中有正确数量的参数

链码函数

func (s *SmartContract) recordProduce(APIstub shim.ChaincodeStubInterface, args []string) sc.Response {

    if len(args) != 5 {
        return shim.Error("Incorrect number of arguments. Expecting 5")
    }

    var Produce = Produce{ProduceName: args[1], Health: args[2], Owner : arg[3], FarmID: args[4]}

    ProduceAsBytes, _ := json.Marshal(Produce)
    APIstub.PutState(args[0], ProduceAsBytes)

    return shim.Success(nil)
}
Invoke.js

'use strict';

const { FileSystemWallet, Gateway } = require('fabric-network');
const path = require('path');

const ccpPath =  path.resolve(__dirname, '..', '..', 'basic-network', 'connection.json');

async function main() {
    try {

        // Create a new file system based wallet for managing identities.
        const walletPath = path.join(process.cwd(), 'wallet');
        const wallet = new FileSystemWallet(walletPath);
        console.log(`Wallet path: ${walletPath}`);

        // Check to see if we've already enrolled the user.
        const userExists = await wallet.exists('user1');
        if (!userExists) {
            console.log('An identity for the user "user1" does not exist in the wallet');
            console.log('Run the registerUser.js application before retrying');
            return;
        }

        // Create a new gateway for connecting to our peer node.
        const gateway = new Gateway();
        await gateway.connect(ccpPath, { wallet, identity: 'user1', discovery: { enabled: false, asLocalhost: true } , eventHandlerOptions: {
            strategy: null
        } 
    });

        // Get the network (channel) our contract is deployed to.
        const network = await gateway.getNetwork('dfarmchannel');

        // Get the contract from the network.
        const contract = network.getContract('produce-app');


        await contract.submitTransaction('recordProduce', 'PR12', 'Banana', 'Good', 'Abhi', 'FARM111');
        console.log('Transaction has been submitted');

        // Disconnect from the gateway.
        await gateway.disconnect();

    } catch (error) {
        console.error(`Failed to submit transaction: ${error}`);
        process.exit(1);
    }
}

main();
错误:

您的源代码有错误消息“参数数量不正确。应为5”,但您得到的是“参数数量不正确。应为6”。 您能确定您使用的是正确版本的链码吗

如果已更新链码,请检查是否已使用正确的源代码和版本号运行了
对等链码安装
对等链码升级