簡體   English   中英

嘗試在松露快遞盒中使用智能合約寫入數據時出現無效地址錯誤

[英]Getting an Invalid Address error when trying to write data with smart contract in truffle express box

我有一個功能,可以將患者的信息插入到映射中,它在混音和松露控制台中運行良好。

function createPatient (uint _SecretNum, string memory _name, uint _dob, string memory _bloodType, string memory _gender, string memory _city,
    string memory allergies,
        bool organDonor,
        string memory emergencyContact) public isWhitelisted(msg.sender)  {

//passing the patient info struct into the new patient mapping
        newPatient[_SecretNum] = patientInfo(_SecretNum, _name, _dob, _bloodType, _gender, _city, allergies,
         organDonor,
        emergencyContact, true);
//calling the event
        emit patientCreate(_SecretNum, _name, _dob, _bloodType, _gender, _city, allergies,
         organDonor,
         emergencyContact, true);
    }

驗證用戶已列入白名單,而且我確信用戶已列入白名單,這是我在函數中輸入字段的代碼

NewPatient: function(id,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact){

    var self = this;
    var data;
    pdata.setProvider(self.web3.currentProvider);

    pdata.deployed().then(function(instance){
      data= instance;
      return data.createPatient(id,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact)
    }).then(function(result){
      console.log('sucess');
    }).catch(function(e){
      console.log(e);

    })

  }

這是我得到的錯誤

Error: invalid address
    at inputAddressFormatter (C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\node_modules\web3\lib\web3\formatters.js:271:11)
    at inputTransactionFormatter (C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\node_modules\web3\lib\web3\formatters.js:97:20)
    at C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\node_modules\web3\lib\web3\method.js:89:28
    at Array.map (<anonymous>)     
    at Method.formatInput (C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\node_modules\web3\lib\web3\method.js:88:32)    
on.js:136:15)    at SolidityFunction.execute (C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\node_modules\web3\lib\web3\function.js:219:37)    at C:\Users\Youssef\Desktop\ExpressBox\node_modules\truffle-contract\contract.js:188:16


----------


所以我任何人都可以看到我看不到的東西我會很感激

所以基本上需要做的是

data.createPatient(123,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact,{from: web3.eth.defaultAccount, gas:3000000});

此版本無法識別 .send 因此作為函數中的額外參數,您可以添加 from: account number

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM