Javascript 错误:返回的值不是';无效,汽油用完了吗?在web3.min.js中

Javascript 错误:返回的值不是';无效,汽油用完了吗?在web3.min.js中,javascript,solidity,smartcontracts,truffle,web3js,Javascript,Solidity,Smartcontracts,Truffle,Web3js,我已经部署了智能合约,我的交易也在metamask中完成,但是当我试图通过调用智能合约的函数来显示我的结果时,我已经检查了数据类型,但我得到了如下错误 Error: Returned values aren't valid, did it run Out of Gas? at i.decodeParameters (web3.min.js:10290) at o._decodeMethodReturn (web3.min.js:12156) at _.outputForm

我已经部署了智能合约,我的交易也在metamask中完成,但是当我试图通过调用智能合约的函数来显示我的结果时,我已经检查了数据类型,但我得到了如下错误

Error: Returned values aren't valid, did it run Out of Gas?
    at i.decodeParameters (web3.min.js:10290)
    at o._decodeMethodReturn (web3.min.js:12156)
    at _.outputFormatter (web3.min.js:12196)
    at _.formatOutput (web3.min.js:7396)
    at u (web3.min.js:7437)
    at web3.min.js:8026
    at s._handle (inpage.js:17) undefined
我不知道为什么它没有解码web3.min.js中的信息,我的js代码是

if (typeof web3 !== 'undefined') {
        web3 = new Web3(web3.currentProvider);
    } else {
        web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
    }

    // Set Contract Abi
    var contractAbi = [{
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "DistributorAdded",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "DistributorRemoved",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": false,
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "Made",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "ManufacturerAdded",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "ManufacturerRemoved",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": false,
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "Packed",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": false,
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "Sold",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "UserAdded",
        "type": "event"
    }, {
        "anonymous": false,
        "inputs": [{
            "indexed": true,
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "UserRemoved",
        "type": "event"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "addDistributor",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "addManufacturer",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "addUser",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": true,
        "inputs": [{
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "fetchMedicineBufferOne",
        "outputs": [{
            "internalType": "string",
            "name": "batchno",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "medicineName",
            "type": "string"
        }, {
            "internalType": "address",
            "name": "ownerID",
            "type": "address"
        }, {
            "internalType": "address",
            "name": "originManufacturerID",
            "type": "address"
        }, {
            "internalType": "string",
            "name": "dosage",
            "type": "string"
        }, {
            "internalType": "enum main.State",
            "name": "medicineState",
            "type": "uint8"
        }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, {
        "constant": true,
        "inputs": [{
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "fetchMedicineBufferTwo",
        "outputs": [{
            "internalType": "string",
            "name": "batchno",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "FactoryName",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "mfgdate",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "expdate",
            "type": "string"
        }, {
            "internalType": "address",
            "name": "distributorID",
            "type": "address"
        }, {
            "internalType": "address",
            "name": "userID",
            "type": "address"
        }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, {
        "constant": true,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "isDistributor",
        "outputs": [{
            "internalType": "bool",
            "name": "",
            "type": "bool"
        }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, {
        "constant": true,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "isManufacturer",
        "outputs": [{
            "internalType": "bool",
            "name": "",
            "type": "bool"
        }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, {
        "constant": true,
        "inputs": [{
            "internalType": "address",
            "name": "account",
            "type": "address"
        }],
        "name": "isUser",
        "outputs": [{
            "internalType": "bool",
            "name": "",
            "type": "bool"
        }],
        "payable": false,
        "stateMutability": "view",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "_medicineName",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "_dosage",
            "type": "string"
        }, {
            "internalType": "address",
            "name": "_originManufacturerID",
            "type": "address"
        }, {
            "internalType": "address",
            "name": "_ownerID",
            "type": "address"
        }, {
            "internalType": "string",
            "name": "_FactoryName",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "_mfgdate",
            "type": "string"
        }, {
            "internalType": "string",
            "name": "_expdate",
            "type": "string"
        }, {
            "internalType": "enum main.State",
            "name": "Made",
            "type": "uint8"
        }, {
            "internalType": "address",
            "name": "_distributorID",
            "type": "address"
        }, {
            "internalType": "address",
            "name": "_userID",
            "type": "address"
        }],
        "name": "makeMedicine",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "packMedicine",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [{
            "internalType": "string",
            "name": "_batchno",
            "type": "string"
        }],
        "name": "receiveMedicine",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [],
        "name": "renounceDistributor",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [],
        "name": "renounceManufacturer",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }, {
        "constant": false,
        "inputs": [],
        "name": "renounceUser",
        "outputs": [],
        "payable": false,
        "stateMutability": "nonpayable",
        "type": "function"
    }]; // Add Your Contract ABI here!!!

    // Set Contract Address
    var contractAddress = '0xd9145CCE52D386f254917e481eB44e9943F39138'; // Add Your Contract address here!!!

    // Set the Contract
    var contract = new web3.eth.Contract(contractAbi, contractAddress);
    $('form').on('submit', function(event) {
        event.preventDefault();
        batchno = $("#batchno").val();
        console.log(batchno)
            //Display the Medicine
        contract.methods.fetchMedicineBufferOne(batchno).call(function(err, result) {
            console.log(err, result)
            $('#ftc-medicine').html(result);

        });
    });
我的智能合约功能是

function fetchMedicineBufferOne(string memory _batchno) public view returns 
  (
    string memory batchno,  //the primary key batchno 
    string memory  medicineName, //Medicine name
    address ownerID, 
    address originManufacturerID, 
    string memory dosage,
    State medicineState
    ) 
  }
return 
  (
    medicines[_batchno].batchno,
    medicines[_batchno].medicineName,
    medicines[_batchno].ownerID,
    medicines[_batchno].originManufacturerID,
    medicines[_batchno].dosage,
    medicines[_batchno].medicineState
    );
}
将创建medicines数组并将值存储在此函数中

function makeMedicine(string memory _batchno, string memory _medicineName,string memory _dosage, address  _originManufacturerID,address _ownerID, string memory _FactoryName, string memory _mfgdate,string memory _expdate,State,address _distributorID,address _userID) public
  
  onlyManufacturer

  {
    // Add the new medicine as part of medicines
    Medicine memory makeMedicine = Medicine({
      batchno:_batchno,  
      medicineName:_medicineName,
      dosage:_dosage,
      originManufacturerID:_originManufacturerID,// Metamask-Ethereum address of the Manufacturer
      ownerID:_ownerID, // Metamask-Ethereum address of the current owner as the medicine moves through 3 stages
      FactoryName:_FactoryName, // Manufacturer Name
      mfgdate:_mfgdate,//mfgdate
      expdate:_expdate,//expdate
      medicineState: State.Made,
      distributorID: _distributorID, 
      userID: _userID

      });
    medicines[_batchno] = makeMedicine;
    medicines[_batchno].medicineState = State.Made;
我在ganache中编译并部署了我的合同,在remix中也进行了部署,其中函数可以正常运行
我在哪里出错?

请编辑您的问题,并显示Solidity函数
fetchMedicineBufferOne()
及其依赖项(例如,它正在调用另一个函数,因此也包括另一个函数)。是的,我添加了我的函数。有人能帮我吗