-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathTajmahal.sol
77 lines (55 loc) · 1.81 KB
/
Tajmahal.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
pragma solidity ^0.4.24;
//author susmit [email protected]
import "./ownable.sol";
import "./erc721.sol";
import "./safemath.sol";
contract Tajmahal is ERC721,Ownable {
using SafeMath for uint256;
struct TajmahalStruct{
string nameId;
string lctn; //location of Tajmahal
address owner; //Owner of Tajmahal
uint price; // price of Tajmahal in ether
}
uint private count = 0;
TajmahalStruct public tajmahal;
mapping(uint => address) TajApproval;
//only one tajmahal can be created ever
function mintToken() public onlyOwner{
require(count < 1);
tajmahal.nameId = "Taj Mahal";
tajmahal.lctn = "India,Agra";
tajmahal.owner = msg.sender;
tajmahal.price = 3;
count = count.add(1);
}
//function to sell tajmahal
function buyTajmahal() public payable {
require(msg.value == tajmahal.price * 10**18);
tajmahal.owner = msg.sender;
}
function setTajmahalPrice(uint _prc) public {
require(msg.sender == tajmahal.owner);
tajmahal.price = _prc;
}
function withdraw() external onlyOwner {
owner.transfer(address(this).balance);
}
function balanceOf(address _owner) public view returns (uint256 _balance){
return 1;
}
function ownerOf(uint256 _tokenId) public view returns (address _owner){
return tajmahal.owner;
}
function transfer(address _to, uint256 _tokenId) public{
require( msg.sender == tajmahal.owner );
tajmahal.owner = _to;
emit Transfer(msg.sender,_to,_tokenId);
}
//no implementation added
function approve(address _to, uint256 _tokenId) public{
}
//no implementation added
function takeOwnership(uint256 _tokenId) public {
}
}