0

I am getting this error when I try to compile

Airlines.sol:49:5: ParserError: Expected '{' but got 'illegal' ➥ public{

Here is the code:

pragma solidity ^0.6.0;    
//SPDX-License-Identifier: UNLICENSED for non-open-source code.  Please see https://spdx.org for more information
    contract Airlines  {
    address chairperson;
    struct details{
        uint escrow; // deposit for payment settlement
        uint status;
        uint hashOfDetails;
    }
    
    mapping (address=>details) public balanceDetails;
    mapping (address=>uint) membership;
    
    // modifiers or rules
    modifier onlyChairperson{
        require(msg.sender==chairperson);
        _;
    }
    modifier onlyMember{
        require(membership[msg.sender]==1);
        _;
    }
    
    // constructor function
    constructor () public payable  {
      
        chairperson=msg.sender;
        membership[msg.sender]=1; // automatically registered
        balanceDetails[msg.sender].escrow = msg.value;
    }
    
    function register ( ) public payable{
        
        address AirlineA = msg.sender;
        membership[AirlineA]=1;
        balanceDetails[msg.sender].escrow = msg.value;
    }
        
   function unregister (address payable AirlineZ) onlyChairperson public {
        if(chairperson!=msg.sender){
            revert(); }
        membership[AirlineZ]=0;
        // return escrow to leaving airline: verify other conditions 
        AirlineZ.transfer(balanceDetails[AirlineZ].escrow);
        balanceDetails[AirlineZ].escrow = 0; 
    }
    
    function request(address toAirline, uint hashOfDetails) onlyMember
    ➥ public{
        if(membership[toAirline]!=1){
            revert(); }
        balanceDetails[msg.sender].status=0;
        balanceDetails[msg.sender].hashOfDetails = hashOfDetails;
    }
    
    function  response(address fromAirline, uint hashOfDetails, uint done) 
                               onlyMember public{
      
        if(membership[fromAirline]!=1){
            revert();  }
        balanceDetails[msg.sender].status=done;
        balanceDetails[fromAirline].hashOfDetails = hashOfDetails;
    }
    
    
function settlePayment  (address payable toAirline) onlyMember payable     
                                       public{
        address fromAirline=msg.sender;
        uint amt = msg.value; 
        balanceDetails[toAirline].escrow = balanceDetails[toAirline].escrow 
                                                   + amt;
        balanceDetails[fromAirline].escrow =      
                balanceDetails[fromAirline].escrow - amt;
       
       // amt subtracted from msg.sender and given to toAirline
        toAirline.transfer(amt
1
  • Please can you insert smart contract's code into a single code sample section? Mar 7, 2022 at 18:33

2 Answers 2

0

Try to set signature of a method in a single line. In your code, change your request() function with this:

function request(address toAirline, uint hashOfDetails) onlyMember public{
        if(membership[toAirline]!=1){
            revert(); }
        balanceDetails[msg.sender].status=0;
        balanceDetails[msg.sender].hashOfDetails = hashOfDetails;
}
0
0

The issue will be resolved if you remove from the code.

Anyway, I would recommend for you go through the style guide for Solidity coding. It would probably make it easier for you to find issues in future, make code more readable and maintainable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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