Lisk Bike PoC
I want to make a project from end to end with Lisk for a while now. I didn’t find the time until now.
Lisk Bike is a Proof of Concept showcasing bike rental on the blockchain. It works with a mobile app as one would expect.
The blockchain provides four custom transactions :
- Create a bike
- Rent a bike
- Return a bike
- Update bike’s location
Create a bike
You can create a bike to rent it on the blockchain. To do that you send a transaction with your bike details : a title, a description, the deposit amount and the price per hour ; you must also provide an ID to clearly identify the bike amount yours, it’s also convenient in case you have a CRM to manage your bikes. Your are free to put any value you want, but it must be unique. The bike is added to your account’s assets.
The deposit amount is the amount the user will see locked upfront before he can rent the bike. It’s a security deposit.
Rent a bike
The transaction to rent a bike is actually based on a transfer transaction. You transfer the deposit amount to the account from which you want to rent a bike from, along with the ID of the bike.
The bike asset is then updated to mark you as the renter and the rent timestamps are set properly. A problem occurs if you want to revert the transaction ! You have erased the previous renter address and timestamps ! To provide an answer to that problem, when you rent a bike you also need to give the last rent transaction and the last return transaction of the bike. So if a revert happens, we can retrieve previous values directly from the transaction !
Return a bike
Nothing unexpected here, we return the renter his deposit minus the cost for the duration of its rental, update bike asset values (renter, timestamps & stuff) and we are done ! Again this transaction requires the last rent & return transactions id, as explained above.
Update bike’s location
The must simple transaction of all : just provide the new location of the bike and it will be updated. Of course you have to be the renter to be able to do that 😉
The mobile application has been developed in React Native. I will not explain how it works since the purpose of this blog is to talk about Lisk Blockchain. I’ll just share a few details.
Since it’s a PoC I decided to make it super straight forward to create an account, you visit the create account page and you are instantly given a new account with some token on it. You can then select a bike and start renting it. To make it easier, the app fetches the last rent transaction and return transaction for you, and include it automatically in the rent & return transactions, with the bike ID of course. You can also visit your account page to see your balance has been updated.
Visit & star the Lisk Bike GitHub repository.