We start with the library for RentOnZilliqa. We declare the one_msg helper function. The source code can be found here.

Message Codes

Then we get to creating a handful of message codes we will use to communicate with the frontend. The codes are of type Int32.

The codes are grouped into three categories:

Account Codes

These codes are general codes that apply to all users that communicate with the contract (the source code).

user_created01Successfully created userInt32
user_exists02User already existsInt32
user_does_not_exist03User does not existInt32
user_is_not_owner04Cannot update/claim commission as user is not ownerInt32
commission_claimed05Commission claimed by ownerInt32
commission_updated06Commission updated by ownerInt32
night_duration_updated07Night Duration updated by ownerInt32

Host Account Codes

These codes are codes specifically used to communicate after actions relating to host accounts (the source code).

listing_created11Successfully created listingInt32
listing_updated12Successfully updated listingInt32
listing_deleted13Successfully deleted listingInt32
rent_claimed14Successfully claimed rent from listingInt32
rent_empty15No accumulated rent for listing being claimedInt32
rent_not_empty16Cannot delete listing as it has accumulated rentInt32
user_is_host17Cannot book listing because user is hostInt32
user_is_not_host18Cannot manage listing because sender is not hostInt32

Renter Account Codes

These codes are codes specifically used to communicate after actions relating to renter accounts (the source code).

listing_booked21Successfully booked listingInt32
listing_unavailable22Cannot book listing because it is rentedInt32
user_is_renter23Cannot create listing as user is a renter accountInt32
wrong_amount_sent24Cannot book listing as amount is wrongInt32
listing_does_not_exist25Cannot book listing because it does not existInt32
listing_details_missing26Listing details are missingInt32

Additional Constants

We define a few more additional constants for use within the contract. We create constants for storing the account roles. As well as some constants for ease of use. (the source code).