-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProductSale.sol
59 lines (51 loc) · 1.35 KB
/
ProductSale.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
pragma solidity ^0.4.0;
contract ProductSale
{
uint saleAmount;
string product;
address owner;
address buyer;
function ProductSale(uint _saleAmount, string _product) public{
saleAmount = _saleAmount;
product = _product;
owner = msg.sender;
}
modifier require(bool _condition) {
if (!_condition) throw;
_;
}
modifier ownerOnly {
if (msg.sender != owner) throw;
_;
}
modifier buyerOnly {
if (msg.sender != buyer) throw;
_;
}
function GetContractAddress() public constant returns (address) {
return this;
}
function GetOwnerAddress() public constant returns (address) {
return owner;
}
function GetBuyerAddress() public constant returns (address) {
return buyer;
}
function BuyProduct() public{
if(msg.sender!=owner)
{
buyer= msg.sender;
}
}
/*function PayAmount()payable public{
if( msg.sender==buyer && msg.value==((10**18)*saleAmount)){
owner.transfer(msg.value);
}
}*/
function PayAmount()payable public
buyerOnly
require(msg.value == ((10**18)*saleAmount))
{
owner.transfer(msg.value);
}
}