我有一个函数,我将患者的信息插入到映射中,它在混音和松露控制台中工作得非常好。
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:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractnode_modulesweb3libweb3formatters.js:271:11)
at inputTransactionFormatter (C:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractnode_modulesweb3libweb3formatters.js:97:20)
at C:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractnode_modulesweb3libweb3method.js:89:28
at Array.map (<anonymous>)
at Method.formatInput (C:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractnode_modulesweb3libweb3method.js:88:32)
on.js:136:15) at SolidityFunction.execute (C:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractnode_modulesweb3libweb3function.js:219:37) at C:UsersYoussefDesktopExpressBoxnode_modulestruffle-contractcontract.js:188:16
----------
所以如果有人能看到我看不到的东西,我会非常感激
所以基本上我们需要做的是
data.createPatient(123,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact,{from: web3.eth.defaultAccount, gas:3000000});
这个版本不认识.send所以作为额外参数的函数可以添加:帐号