-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseller.sol
62 lines (51 loc) · 1.37 KB
/
seller.sol
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
pragma solidity ^0.4.16;
contract seller{
address owner;
struct product {
uint price;
uint productid;
bool Status;
bool buyer ;
}
bytes32 public Hash;
product public Product;
mapping(uint => product ) products;//mapping each product id with product
function seller(uint Productid ,uint Random)payable {
owner =msg.sender;
Hash=sha256(Productid,Random);
Product = products[Productid];
Product.price=msg.value;
Product.productid = Productid;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function() payable {
}
function Payback (){
if(Product.Status){
owner.transfer(2*Product.price);
Product.Status=false;
}
}
function boolBuyer() view public returns (bool){
return Product.buyer;
}
function boolBuyerEdit() {
Product.buyer=true;
}
function boolStatusEdit() {
Product.Status=true;
}
function boolStatus() view returns (bool){
return Product.Status;
}
function ContractsBalance () view returns (uint){
return address(this).balance;
}
//for test purpose--only owner can check his balance
function SellersBalance ()onlyOwner view returns (uint){
return owner.balance;
}
}