A Winding Tree tutorial

  • Create an Hotel on the blockchain with one room
  • Book this room for 5 days.
$ cd /tmp
$ git clone https://github.com/windingtree/wt-contracts --recursive
$ cd wt-contracts
$ npm install
  • We don’t have to pay real money to interact with the blockchain,
  • We do not have to synchronize all the blockchain on our computer,
  • We do not need to wait for the mining processes
$ truffle develop
Truffle Develop started at http://localhost:9545/
Accounts:
(0) 0x627306090abab3a6e1400e9345bc60c78a8bef57
(1) 0xf17f52151ebef6c7334fad080c5704d77216b732
(2) 0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef
(3) 0x821aea9a577a9b44299b9c15c88cf3087f3b5544
(4) 0x0d1d4e623d10f9fba5db95830f7d3839406c6af2
(5) 0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e
(6) 0x2191ef87e392377ec08e7c08eb105ef5448eced5
(7) 0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5
(8) 0x6330a553fc93768f612722bb8c2ec78ac90b3bbc
(9) 0x5aeda56215b167893e80b4fe645ba6d5bab767de
Mnemonic: candy maple cake sugar pudding cream honey rich smooth crumble sweet treattruffle(develop)>
> compile
> deploy
WT Hotel MVP Contract Hierarchy (simplified)
> WTIndex.new().then(instance => wt = instance)
> wt.address
'0xf25186b5081ff5ce73482ad761db0eb0d25abfbf'
> wt.registerHotel('My Hotel','A very nice Hotel')

> wt.getHotelsByManager(web3.eth.coinbase)
[ '0xf2beae25b23f0ccdd234410354cb42d08ed54981']
> wt.getHotelsByManager(web3.eth.coinbase).then(addr => h = Hotel.at(addr[0]))
> h.name()
'My Hotel'
> h.description()
'A very nice Hotel'
> UnitType.new(h.address, 'BASIC_ROOM').then(i => ut = i)
> Unit.new(h.address, 'BASIC_ROOM').then(i => u = i)
> h.addUnitType(ut.address)
Error: VM Exception while processing transaction: invalid opcode
> wt.callHotel(0, h.contract.addUnitType.getData(ut.address))
> wt.callHotel(0, h.contract.addUnit.getData(u.address))
  • Instantly with Winding Tree native token LIF
  • With a confirmation mechanism with other payment options.
> wt.callHotel(0, h.contract.changeConfirmation.getData(true))
  • A private one with the guest details
  • A public one with the details of the hotel being booked and the dates.
Example of guest private data
> privateData = "PRIVATE_GUEST_DATA"
> publicData = h.contract.book.getData(u.address, web3.eth.coinbase, 20150, 5)
> h.beginCall(publicData, privateData).then(i => beginCalltx = i)
> abiDecoder = require('abi-decoder')
> abiDecoder.addABI(Hotel._json.abi)
> beginCallEvent = abiDecoder.decodeLogs(beginCalltx.receipt.logs)[0]
> beginCalltxCode = web3.eth.getTransaction(beginCalltx.tx).input
> transferDecoded = abiDecoder.decodeMethod(beginCalltxCode)
> abiDecoder.decodeMethod(transferDecoded.params[0].value)
{ name: 'book',
params:
[ { name: 'unitAddress',
value: '0xf25186b5081ff5ce73482ad761db0eb0d25abfbf',
type: 'address' },
{ name: 'from',
value: '0x627306090abab3a6e1400e9345bc60c78a8bef57',
type: 'address' },
{ name: 'fromDay', value: '20150', type: 'uint256' },
{ name: 'daysAmount', value: '5', type: 'uint256' } ] }
> web3.toAscii(transferDecoded.params[1].value)
'PRIVATE_GUEST_DATA'
> pendingCallHash = beginCallEvent.events[1].value
> wt.callHotel(0, h.contract.continueCall.getData(pendingCallHash))
> u.getReservation(20150)
[ BigNumber { s: 1, e: 0, c: [ 0 ] },
BigNumber { s: 1, e: 0, c: [ 0 ] },
'0x627306090abab3a6e1400e9345bc60c78a8bef57' ]
> h.beginCall(publicData, privateData)
Error: VM Exception while processing transaction: invalid opcode
  • Scalability: The current cost to setup an hotel is quite high (in gas fees) as we need to send multiple transactions to create each unit type and units and configure them. Frequent updates to the inventory are also required when some works are being done in a given room. A descriptive file stored out of the contract for example in IPFS or SWARM would be much better. Also some general evolutions of Ethereum with the move to Proof-of-Stake and State Channels should greatly improve the situation.
  • Privacy: With the current mechanism, it’s relatively trivial with the Hotel Contract ABI to retrieve the guest private data. We have voluntary put in the example a credit card to raise the question of PCI-DSS Compliancy. There is also GDPR in Europe. How is this data going to be secured? Also some Travel Agencies have private rates as a result of business negotiations, should this data be public?
  • Duplicates and Fake listings: Nothing prevents a bad actor to create a fake Index, fake Hotels and so on. They can even generate a lot of dummy reservations to make it appear legit. How is the Travel Agency and ultimately the traveler protected from this situation? It’s not acceptable to have a traveler getting to an Hotel to find there is nothing here, or worst. Any serious implementation will need to put in place a great deal of measures to ensure they have the good contract address to an hotel that do exist in the physical world.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
The Travel Tech

The Travel Tech

Traveller and technology enthusiast, I am sharing my experiments and thoughts on technology applied to the travel industry. Get in touch at https://noath.net !