Last active
June 27, 2018 07:15
-
-
Save skfarhat/a00342d36dbe763ce239ccf4c6515d1e to your computer and use it in GitHub Desktop.
WIP: AirBnB implementation in Ethereum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.22; | |
contract EthBnB { | |
struct Room { | |
/** | |
* NOTE: we'll likely want to use another form of identifier for rooms | |
*/ | |
uint roomId; | |
uint price; | |
address owner; | |
string location; | |
/** | |
* maps 'date' of booking to address. | |
* The 'date' is now represented as string | |
*/ | |
mapping(string => address) bookingDates; | |
} | |
/** | |
* increments for every room that is created | |
*/ | |
uint roomId = 1; | |
/** | |
* maps 'roomId' to Room | |
*/ | |
mapping(uint => Room) rooms; | |
/** | |
* creates a new room for the message sender | |
*/ | |
function createRoom() { | |
rooms[roomId] = Room({ | |
roomId : roomId | |
}); | |
} | |
/** | |
* only the room owner can execute this function | |
*/ | |
function makeRoomAvailable(uint roomId, uint price, string []dates) public { | |
// the message sender must be the owner of the room | |
require(rooms[roomId].owner == msg.sender); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment