Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP 808 - ERC for a Standard Decentralized Booking Protocol #808

Closed
wants to merge 16 commits into from
124 changes: 124 additions & 0 deletions EIPS/eip-770.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
## Preamble

EIP: 770 <or to be assigned an editor>
Title: Decentralized Booking Protocol Standard
Author: Vidal Chriqui <vidal@btuprotocol.com>
Type: Standard
Category : ERC
Status: Draft
Created: 2017-12-20
Requires : ERC 20
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra space before :.

Requires: 20
should be fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be done in next submission


## Abstract

The following describes standard functions for a decentralized booking protocol that can be used to reserve any kind of resource (Hotel, concert ticket, restaurant table).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hotel-->hotel room?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hotel room

The protocol involves following participants :

- Provider : an entity providing its own resource or a third-party party resource to be booked
- Booker : an entity that books the resource for itself or a third party
- Booking infrastructure : a public "location" where providers can "post" resource availability data and where these resources can be searched by bookers. The booking infrastructure facilitates signaling between providers and bookers by aggregating a high volume of resource type and availabilities.
- RES : A booking smart contract implementation of the decentralized standardized BTU protocol.

## Motivation

The Booking Token Unit (BTU) protocol is a building block for any decentralized application (dApp) or web site willing to implement booking features for their end-users.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the name of the protocol

  • The Booking Token Unit protocol, or
  • Decentralized Booking Protocol?

If these two are different protocols, where is the Booking Token Unit protocol described?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is only one protocol, the "Booking Token Unit protocol" that is the subject of this ERC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The title reads differently.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title was not meant to name the protocol, but thanks for this valuable feedback, I adjusting the title accordingly

This standard also brings interoperability among decentralized applications that incorporate it.
We strongly believe that a transparent and public inventory enabled by an open-source standardized protocol would considerably lower the entry barriers to many Internet booking markets.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra space after a.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed in next submission


## Specification

The BTU protocol involves potentially ten steps and our standardized decentralized reservation contract (RES). Some of following steps can be relayed off-chain, but are always settled on-chain.

<img src="./eip-770/protocol-steps.png">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image contains an Ethereum logo. Ethereum logos are distributed under Creative Commons Attribution 3.0. Please follow the term of the license.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this reminder that will be taken into account in next submission


Hereafter the general sequence :
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra space before :.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be fixed in next submission


(Step 1.1) Provider is creating an “availability offer” (OFFER) specifying :

* resource id OR bundle id. A bundle is a group of resources.
* resource name OR bundle name
* resource category
* deposit amount in BTU : amount requested for escrow in order to allow a reservation request
* commission amount in BTU : amount paid to booker
* availability start date,
* availability end date
* limit date and time for a free reservation cancellation
* signed (r,s,v) hash of previous information. This signed hash serves as a signed identifier of the resource to be reserved.
* Metadatas : daily price of the resource (fiat amount to be paid at resource “delivery”), links to images, long description, key-values that can be used as search criteria, etc...
The availability data is broadcasted over any communication channel, ideally a decentralized off-chain solution.

(Step 1.2) At any moment, the provider can update the resource metadata by broadcasting a new message.
It is very common that yield management requires many prices (fiat price of the resource) update during the same day. This update only impacts the off-chain components.

(Step 2) Booker is looking for a resource is querying all resources matching is criteria and is selecting a resource he is willing to reserve

(Step 3.1) In the same operation :
Booker is approving to RES smart contract the required amount of BTU to make the booking (amount defined in step 1.1 by the provider)
A booking entry is registered into the smart contract with following information

* Signed hash of resource
* Signed pointer to all full offer information (datas + metadatas) at the moment of the reservation request. Those information are stored in the offchain booking infrastructure.
* Public address matching the hash signature
* desired reservation start date
* desired reservation end date
* status : RESERVATION_REQUESTED

(Step 3.2) Booker broadcasts the resource reservation request to the Booking infrastructure adding all end-user profile information off-chain that may be necessary for the reservation approval. This would help comply with privacy protection requirements.
It is the responsibility of the Booker to notify its end user customer of the full resource information and the provider signature (Availability “snapshot” data). This can be used as proof of reservation details in (the extreme) case resource information at reservation time is deleted from off-chain infrastructure.

(Step 4) Provider is validating the reservation request and broadcasts the new status to “RESERVATION_CONFIRMED”.

(Step 5) RES smart contract is updating the reservation status to “RESERVATION_CONFIRMED”

(Step 6.1 - Optional) Booker cancels the reservation by broadcasting a cancellation request. This triggers a submission to the RES smart contract that empties the registries for this resource.
Depending on the conditions and cancellation date, the BTU escrowed into the RES smart contract are affected back to the user or to the provider

(Step 6.2 - Optional) Provider cancels the reservation by broadcasting a cancellation request. This triggers a submission to the RES smart contract that empties the registries for this resource. RES smart contract is releasing the escrowed amount to booker.

(Step 7.1 & 7.2) Booker is notifying that the resource has been paid (presumably at resource check-out). RES smart contract is releasing the escrowed BTU back to user in addition to a BTU agreed commision.
Copy link
Member

@pirapira pirapira Jan 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: commision should be commission.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be fixed in next submission


## Implementation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation section is supposed to contain links to testable code.


The implementation involves following functions :

- publishAvailabilities (likely off-chain) : Publishes one or multiple available resources for reservations and for being “searchable”.
- listAvailabilities (likely off-chain) : List all available resources matching a search criteria
- requestReservation : Request for a reservation. The function can be used for initial reservation request OR updating
- getReservationStatus : Read reservation status. Following values are possible : REQUESTED, REJECTED, CONFIRMED


```
contract ERC770 is ERC20 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this need to be an ERC20?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because during the process (step 3.1 or6.1 for instance), the allowance & approve may be called by the RES smart contract

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RES contract doesn't need to be an ERC20 contract for calling allowance or approve. The callee needs to be ERC20, but the caller doesn't need to.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my quick reply.
You are right, RES smart contract does not have to be ERC20, however in the sample implementation we are doing it (but not required). Still, the BTU tokens have to ERC20 compliant.
I realize that my description can this code sample is confusion and that it's more clear to separate the token from the RES contract.
This (valuable) feedback will be taken into account in next submission to make things more clear.

// Availability structure
enum BookingStatus { REQUESTED, REJECTED, CONFIRMED, CANCELLED }
struct availability {
address _contractAdress;
uint _resourceId ; // resource id OR bundle id
uint _type; // Type of Availability
uint _minDeposit ; // minimum BTU deposit for booking this resource
uint _commission ; // commission amount paid to booker in BTU
uint _freeCancelDateTs; // Limit date for a reservation cancellation
uint _statDateTs; //availability start date timestamps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo _startDateTs

uint _endDateTs; //availability end date timestamps
BookingStatus _bookingStatus ; // reservation status
string _metaDataLink // Link to Meta Data of the bookable resource (desc, image links, etc…)
}
//Submit one or multiple availability - implementation will be off-chain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does an offchain functionality appear in the interface of an Ethereum contract?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did this for pedagogical reasons (easier to understand).
Also, because sample implementation may implement on-chain functions (for testing without scalability)

function publishAvailabilities (address _owner, availability[] _availability, bytes32 signatureProof ) constant returns (uint status);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A _ seems to be missing in front of signatureProof.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

//Query Availabilities - implementation will be off-chain
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does an offchain functionality appear in the interface of an Ethereum contract?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did this for pedagogical reasons (easier to understand).
Also, because sample implementation may implement on-chain functions (for testing without scalability)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If an implementation has this function on-chain, is the implementation still compliant to this ERC?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Because the ERC specified "eventually" off-chain (not mandatory to be off-chain)

function ListAvailabilities(address _requester, string _criterias) constant returns (availability[] a);
//Request reservation
function requestReservation(address _requester, availability _availability) constant returns (uint status);
//Check booking status
function getReservationStatus(address _requester, availability _availability) constant returns (BookingStatus status);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is status sometimes BookingStatus and sometimes uint?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this relevent remark. The correct type is BookingStatus and this mistake came from a bad copy and paste (from a previous code base)

}
```

## Additional References

[BTU website](http://www.btuprotocol.com)


## Copyright

All contributions are made under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.en.html)