简体   繁体   English

尝试在松露快递盒中使用智能合约写入数据时出现无效地址错误

[英]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.

相关问题 尝试运行智能合约时出现解析器错误 - Parser error when trying to run a smart contract 尝试使用松露合同从节点js部署合同时出现错误 - Getting Error when try to deploy contract from node js using truffle-contract 我试图在 remix ide 中编写一个简单的智能合约,并一次又一次地遇到一般错误。 下面是我的代码和错误 - I am trying to write a simple smart contract in remix ide and getting encountered by a generic error again and again. Below is my code and error 尝试在 Windows Powershell 上安装 Truffle 时出错 - Getting an error when trying to install Truffle on Windows Powershell 我尝试在 truffle 中部署我的智能合约,但是当我“truffle 迁移”时显示“不受支持的编译器”,我该如何解决这个问题? - I try to deploy my smart contract in truffle but is says "unsupported compiler" when I "truffle migrate" how can I fix this? 使用 Node.js 编译和部署以太坊智能合约时出错 - Getting error when compiling and deploying ethereum smart contract with Node.js 在 windows 上安装 TRUFFLE 时出错 - Getting a error when installing TRUFFLE on windows 测试我的 Solidity 智能合约时遇到问题(带松露) - Having a Problem Testing my Solidity Smart Contract (w/ Truffle) 在 docker 上的私有区块链节点上使用 truffle 部署智能合约 - Deploying smart contract using truffle on private blockchain node on docker 使用Web 3连接到智能合约时出错 - Getting error while connecting to smart contract using web 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM