-2

browser/Logistics.sol:60:14: ParserError: Expected '(' but got identifier function OrderItem(uint _itemid, string _itemname) public returns(address){ ^-------^


pragma solidity ^0.4.24;

contract Logistics {

    //////////////////////DECLARATION/////////////////

      struct package{
         bool isuidgenerated;
         uint itemid;
         string itemname;
         string transitstatus;
         uint orderstatus; // 1 = ordered; 2 = in-transist; 3 = delivered; 4 = canceled
        address Owner;
         address customer;
         uint ordertime;

         address carrier1;
         uint carrier1_time;

         address carrier2;
         uint carrier2_time;

        address carrier3;
         uint carrier3_time;

}

     mapping (address => package) public packagemapping;
     mapping (address => bool) public carriers;

    ////////////////////DECLARATION END///////////////

////////////////////////MODIFIERS//////////////////

 constructor(){
     Owner = msg.sender;
 }
 modifier onlyOwner(){
     require(Owner = msg.sender);
     _;
 }
//////////////////////MODIFIERS END////////////////

///////////////MANAGE CARRIERS/////////////////////

function ManageCarriers(address _carrierAddress) onlyOwner public returns (string){

if (!carriers[_carrierAddress]){
      carriers[_carrierAddress] = true;
  } else {
      carriers[_carrierAddress] = false;     
  }
return "Carrier is updated";

///////////////MANAGE CARRIERS END /////////////////////



//////////////////////////ORDERITEM FUNCTION///////////////////////
    function OrderItem(uint _itemid, string _itemname) public returns(address){
        address uniqueId = address(sha256(msg.sender, now));

       packagemapping[uniqueId].isuidgenerated = true;
       packagemapping[uniqueId].itemid = _itemid;
       packagemapping[uniqueId].itemname = _itemname;
       packagemapping[uniqueId].transitstatus = "your package is ordered and is under processing";
       packagemapping[uniqueId].orderstatus = 1;

       packagemapping[uniqueId].customer = msg.sender;
       packagemapping[uniqueId].ordertime = now;

        return uniqueId;

}

/////////////////////////////ORDER FUNCTION END ///////////////////
}
  • You're at least missing } at the end of function ManageCarriers. Please also format your code properly, it's very impossible to read currently – Lauri Peltonen Jan 28 at 7:37
  • Also, by formatting your code properly you'd be able to see the error yourself... – Richard Horrocks Jan 28 at 9:15
0

You were missing a } in ManageCarriers as @Lauri mentioned, also you declared Owner in a struct and then you are initializing it independently in constructor, that is also an error. Also please format you code properly before pasting here and use <pre><code> to enclose it.

pragma solidity ^0.4.24;

contract Logistics {

//////////////////////DECLARATION/////////////////


    address Owner;

  struct package{
     bool isuidgenerated;
     uint itemid;
     string itemname;
     string transitstatus;
     uint orderstatus; // 1 = ordered; 2 = in-transist; 3 = delivered; 4 = canceled
     address customer;
     uint ordertime;

     address carrier1;
     uint carrier1_time;

     address carrier2;
     uint carrier2_time;

    address carrier3;
     uint carrier3_time;
}

 mapping (address => package) public packagemapping;
 mapping (address => bool) public carriers;

////////////////////DECLARATION END///////////////
////////////////////////MODIFIERS//////////////////

constructor () public
{ 
    Owner = msg.sender; 

} 
modifier onlyOwner(){ 
    require(Owner == msg.sender); _; 

} //////////////////////MODIFIERS END////////////////

///////////////MANAGE CARRIERS/////////////////////

function ManageCarriers(address _carrierAddress) onlyOwner public returns (string){

if (!carriers[_carrierAddress]){ carriers[_carrierAddress] = true; } else { carriers[_carrierAddress] = false;
} return "Carrier is updated";
}

///////////////MANAGE CARRIERS END /////////////////////

//////////////////////////ORDERITEM FUNCTION///////////////////////
function OrderItem(uint _itemid, string _itemname) public returns(address){
    address uniqueId = address(sha256(abi.encodePacked(msg.sender, now)));
   packagemapping[uniqueId].isuidgenerated = true;
   packagemapping[uniqueId].itemid = _itemid;
   packagemapping[uniqueId].itemname = _itemname;
   packagemapping[uniqueId].transitstatus = "your package is ordered and is under processing";
   packagemapping[uniqueId].orderstatus = 1;

   packagemapping[uniqueId].customer = msg.sender;
   packagemapping[uniqueId].ordertime = now;

    return uniqueId;
}

/////////////////////////////ORDER FUNCTION END /////////////////// 

}
  • browser/Logistics.sol:60:10: ParserError: Expected '(' but got identifier function OrderItem(uint _itemid, string _itemname) public returns(address){ ^-------^ – bhemeswararao ankireddy Jan 28 at 8:25
  • any one help me – bhemeswararao ankireddy Jan 28 at 8:25
  • @bhemeswararaoankireddy use the code I've pasted above or just add } at the end of ManageCarriers function, your code is missing that. – sp4c3 Jan 28 at 8:52

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.