Skip to content

Instantly share code, notes, and snippets.

@skfarhat
Last active June 27, 2018 07:15
Show Gist options
  • Save skfarhat/a00342d36dbe763ce239ccf4c6515d1e to your computer and use it in GitHub Desktop.
Save skfarhat/a00342d36dbe763ce239ccf4c6515d1e to your computer and use it in GitHub Desktop.
WIP: AirBnB implementation in Ethereum
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