0

I have 2 contracts - user and property.

A person who is registered on the website through function registeruser in contract user, can only buy or sell a property in contract property.

I have a function named CheckReg in contract user, which checks whether or not a person who tries to buy or sell a property in contract property is registered.

I have deployed contract user on the blockchain.

Now my question is how do I access the state of a person that whether he is registered or not in contract user in contract property.

Code is given below.

Thanks in advance.

//userContract
pragma solidity ^0.4.25;

contract User{

struct UserInfo{

 string Name;

 string EmailAddress;

 uint Age;

 uint PhoneNo;

 uint Cnic; 

 uint Id;

 }

 uint TotalNoOfUsers=1;

 bool Status;

 address owner=0xca35b7d915458ef540ade6068dfe2f44e8fa733c;

 mapping(address=>UserInfo)UserData;

 mapping(uint=>address)IdToUserData;

  modifier CheckingRegisteration{

 if(UserData[msg.sender].Id==0){

 _;

  }

}

 modifier OnlyOwner{

 if(msg.sender==owner){

   _;

  }

 }

function checkregistered(address ss) public returns (bool){

  if(UserData[ss].Id!=0){

  return true;

 }

 else{

  return false;
          }
    }
    function RegisterUser(string _Name, string _Email, uint _Age, uint _PhoneNo, uint _Cnic) public CheckingRegisteration returns (bool){

 if(GetRegistrationStatus()==true){
         UserData[msg.sender]=UserInfo(_Name,_Email,_Age,_PhoneNo,_Cnic,TotalNoOfUsers);

  IdToUserData[TotalNoOfUsers]=msg.sender;

 TotalNoOfUsers++;

 return true;
        }
    }

 function SetRegisterationStatus(bool _Status) OnlyOwner public{

  Status=_Status;


  }

 function GetRegistrationStatus()public view returns(bool){

  return Status;

 }
}

//propertyContract

pragma solidity ^0.4.25;
import './User1.sol';
contract Property {

struct PropertyFeatures{

 string Type;

 uint Price;

 uint Bedrooms;

 uint Bathrooms;

 uint YearBuilt;

 uint Floors;

 uint Area;

string Description;

 string Location;

 string City;

 }



 uint TotalNoProperties=1;

mapping(address=>PropertyFeatures[])UserProperty;

 mapping(uint=>PropertyFeatures)PropertyId;

 function SetProperty(string _type, uint _Price, uint _Bedrooms, uint _Bathrooms, uint _YearBuilt,uint _Floors,uint _Area, string _Description,string _Location,string _City) public returns (bool)
{

UserProperty[msg.sender].push(PropertyFeatures(_type,_Price,_Bedrooms,_Bathrooms,_YearBuilt,_Floors,_Area,_Description,_Location,_City));
       PropertyId[TotalNoProperties]=PropertyFeatures(_type,_Price,_Bedrooms,_Bathroom,_YearBuilt,_Floors,_Area,_Description,_Location,_City);

 TotalNoProperties++;

 return true;

 } 


 function getuserreg() public returns(bool){

 address USERCONTRACTADDRESS=0x692a70D2e424a56D2C6C27aA97D1a86395877b3A;

if(USERCONTRACTADDRESS.call(bytes4(keccak256("checkregistered(address)")),msg.sender)==true){

return true;

}else{

 return false;

 }

  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.