首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在松露速递箱中尝试用智能契约写入数据时,获取无效地址错误

在松露速递箱中尝试用智能契约写入数据时,获取无效地址错误
EN

Stack Overflow用户
提问于 2022-07-04 07:59:28
回答 1查看 112关注 0票数 1

我有一个功能,我将病人的信息插入到映射中,它在混合和松露控制台上非常好地工作。

代码语言:javascript
复制
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);
    }

验证了用户是否已被白化,而且我确信用户已经被白化了,这是我将字段输入函数的代码。

代码语言:javascript
复制
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);

    })

  }

这就是我所犯的错误

代码语言:javascript
复制
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


----------

所以我任何人都能看到一些我无法理解的东西我很感激

EN

回答 1

Stack Overflow用户

发布于 2022-07-06 10:54:17

所以基本上我们需要做的是

代码语言:javascript
复制
data.createPatient(123,Pname,Pdob,bloodRes,GenderRes,SelectedCityValue,allergies,donor,Econtact,{from: web3.eth.defaultAccount, gas:3000000});

此版本不识别.send,因此可以在函数中添加from: account号作为额外参数。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72853455

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档