0

I don't know where the error is coming from? I changed the compiler from 0.8.17 to 0.8.0 but the constrcutor function keeps showing this error. "ParserError: Expected pragma, import directive or contract/interface/library/struct/enum/constant/function/error definition." on the constructor function

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; 
contract MedicalKeyEncapsulation {
    address  public Doctor;
    address  public Patient;
    bytes32 private encapA;  
    bytes32 private encapB; 
}

    struct Patientdata{
        string pName;
        uint256 PID;
        uint256 Date;
        string disesaseinfo;
    }

     struct DocRecord{
        string DocName;
        uint256 DID;
        uint256 Date;
        string specialiazation;
        bytes32 hcn_hash;
    }

   

    constructor (address _Patientdata, address _DoctorRecord) public {
    Patient = msg.sender;
    Doctor =_Doctor;
   }
}

1 Answer 1

0

You have 1 curly bracket after your variables declaration that ends your contract. Fixed below

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; 
contract MedicalKeyEncapsulation {
    address  public Doctor;
    address  public Patient;
    bytes32 private encapA;  
    bytes32 private encapB; 


    struct Patientdata{
        string pName;
        uint256 PID;
        uint256 Date;
        string disesaseinfo;
    }

     struct DocRecord{
        string DocName;
        uint256 DID;
        uint256 Date;
        string specialiazation;
        bytes32 hcn_hash;
    }

   

    constructor (address _Patientdata, address _DoctorRecord) public {
    Patient = msg.sender;
    Doctor =_Doctor;
   }
}

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.