-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProperty.sol
More file actions
92 lines (75 loc) · 2.56 KB
/
Property.sol
File metadata and controls
92 lines (75 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
pragma solidity >=0.4.16 <0.9.0;
contract Property{
string addressOfProperty;
address payable owner;
address payable interested;
string id;
uint Pincode;
struct PropertyPapers{
uint houseNumber;
uint RegistrationNumber;
}
enum StateOfHouse{
Unintended,
ForSale,
DealPending,
NegotiationSuccessFul,
PaymentDone,
TransferSuccessful
}
StateOfHouse state;
mapping (address => string) request;
mapping (address => uint) price;
uint priceFinal;
PropertyPapers papers;
modifier ForOwnerFunctions(){
require( msg.sender == owner
,"You are Not The Owner Man, How are you trying to Do this thing, Just Go Away");
_;
}
constructor (string memory idOfProperty , string memory addOfProperty , uint regnr , uint housern , uint postalCode) public {
owner = payable(msg.sender);
papers= PropertyPapers(housern, regnr);
addressOfProperty = addOfProperty;
Pincode = postalCode;
id = idOfProperty;
state = StateOfHouse.Unintended;
}
function getOwner() public view returns(address){
return owner;
}
function setForSale() public ForOwnerFunctions(){
state = StateOfHouse.ForSale;
}
function sendRequest(string memory message, uint dealprice) public {
require(state == StateOfHouse.ForSale,
"You cannot do this deal sorry it is not for sale currently");
request[owner] = message;
price[owner] = dealprice;
state=StateOfHouse.DealPending;
interested = payable( msg.sender);
}
function readRequest() public ForOwnerFunctions() view returns (string memory){
return request[msg.sender];
}
function readPrice() public ForOwnerFunctions() view returns (uint){
return price[msg.sender];
}
function doneDeal() public ForOwnerFunctions() {
state=StateOfHouse.NegotiationSuccessFul;
priceFinal = price[msg.sender];
request[interested] = "I accept the deal! Payment Due!";
}
function dealConditions() public view returns(string memory){
require(state == StateOfHouse.NegotiationSuccessFul,
"Not yet Finalised!");
return request[interested];
}
function doPayment() public {
address payable _owner = owner;
_owner.send(priceFinal);
state = StateOfHouse.PaymentDone;
owner = payable(interested);
state = StateOfHouse.TransferSuccessful;
}
}