In this section, we will go through the process of writing the Scilla Contract for RentOnZilliqa. The contract will be deployed using the Scilla IDE.
The logic of the contract is planned with the point of view of a renting platform. As such, we act as the renting platform and hence the owner of the contract. We collect a fixed commission from every rental transaction on the contract. The source code for the contract can be found here.
Listings are the houses that can be posted on the platform, which are subsequently made available to the renters.
We allow the creation of user accounts to facilitate using the platform. The accounts can have one of two roles:
- A Renter Account
- A Host Account
Renter Accounts can rent listings that are created on the platform. When the correct amount is sent for booking an available listing, the listing is made available to the renter account.
Host Accounts can create and manage listings on the platform. They can collect revenue from their listings. Hosts can also rent listings as long as they do not own the listing.
Our contract has one immutable variable, i.e.,
owner of type
ByStr20. We use this to store the wallet address of the contract owner.
Since listings can be rented for a limited amount of time, we need to devise a way of tracking the passage of time. We do this by measuring the change in the
BLOCKNUMBER. In the following sections, we will see in detail how this is achieved.
In the coming sections, we will build the contract. We will go through the following stages in detail: