[英]Getting an Invalid Address error when trying to write data with smart contract in truffle express box
I have a function where I insert patient's info into a mapping and it works perfectly fine on remix and in the truffle console.我有一个功能,可以将患者的信息插入到映射中,它在混音和松露控制台中运行良好。
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);
}
There is a verification that the user is whitelisted and also I am sure the user is whitelisted anyway this is the code where I input the fields into the function验证用户已列入白名单,而且我确信用户已列入白名单,这是我在函数中输入字段的代码
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);
})
}
And this is the error I get这是我得到的错误
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
----------
So I anyone can see something I can't I would appreciate is so much所以我任何人都可以看到我看不到的东西我会很感激
So basically what was needed to do is所以基本上需要做的是
data.createPatient(123,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact,{from: web3.eth.defaultAccount, gas:3000000});
this version did not recognize .send so as an extra parameter in the function you can add the from: account number此版本无法识别 .send 因此作为函数中的额外参数,您可以添加 from: account number
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.