A project based on introducing a real estate app in the near blockchain which makes the process of aquiring residential places to stay much easier.
- Rust Programming Language
- Shell
- near-sdk-rs library
This contract enable users logged in using their near accounts to be able to update their account details, see properties added by them or other users and add a new property to sale
Assuming we had two men, Brian and Felix.
- Brian has a set of houses he needs to rent,
- Felix on the other hand is looking for a place to stay... Maybe he is new in town meaning he doesn't know anything about the town or anyone within.
- Assuming both of them registered in the app, Brian would raise a notification by adding his properties and storing them on the app.
- Since Felix is in need of the house at that particular time, He will be able to view the housed added by brian and choose which one he wants to stay on.
User must log in to the near cli using his account id to be able to interact with the contract.
once the user has logged in he can then add properties based on the fields like the property name, price and description. upon addition. some fields get filled automatically, like the ID auto increments depending on the length of our storage. the owner of the property is also added automatically as the field is filled with the current id involved in the function execution
Of course the buyer will need to see the full description, location and price to judge out the kind of taste he or she would like to settle into. when as long as he is logged in, he is able to list the properties and view all of them
The customer is able to buy a property in our app, we assume that the price of the property we added earlier is in near. when a property is bought, the status of the property changes to bought and an amount equal to the price is sent to the owner of the property.
A user can update and view his account details at his own pleasure.
A user could also count the number of properties and users registered in the contract
Root Folder
.
├── build.sh
├── Cargo.lock
├── Cargo.toml
├── deploy.sh
├── dev-deploy.sh
├── init-args.js
├── LICENSE
├── README.md
├── rustfmt.toml
└── src
├── lib.rs
└── wasm
- run
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
- Configure your current shell by running
source $HOME/.cargo/env
- Add a wasm target to your tool chain by running
rustup target add wasm32-unknown-unknown
Depending on your operating systems, for example mine is fedora. i would run the following code on the terminal.
sudo dnf install nodejs
For windows users you would download nodejs from their official website. with the link below https://https://nodejs.org/ nodejs is needed to run our near cli which we would discuss on how to install it in the next step
to install the near cli run the following code in your terminal
npm install -g near-cli
Type near login
in your terminal, you shall be redirected to a browser that looks like this.
to clone my code, you can either download it directly from github or run git clone https://github.com/Felabs1/near-real-estate.git
in your terminal
navigate to the contract folder, open terminal and run ./build.sh
if you need to build the app
run ./test.sh
if you need to test the app.
In this step i presume you managed to compile and test the code successfully. the .wasm file was generated then copied to wasmfile folder for easier accessibility.
near deploy $accountname.testnet --wasmFile ./wasmfile/near_real_estate.wasm
- reg_user (Registering a user)
near call $account.testnet reg_user '{"name": "Felabs", "usertype": "owner", "contact": "0111942081"}' --accountId $account.testnet
- new_property (Adding a new Property)
near call $account.testnet new_property '{"property_name": "Felabs Apartments", "price": 3, "location": "Kisumu", "description": "a very nice place to recide in"}' -- accountId $account.testnet
- count_properties (counting properties)
near call $account.testnet count_properties --accountId $account.testnet
- edit_account (editing your user details)
near call $account.testnet edit_account '{"name": "Felabs", "usertype": "customer", "contact": "0111942081"}' --accountId $account.testnet
- view_account (viewing your account details)
near call $account.testnet view_account --accountId $account.testnet
- list_properties (listing all properties)
near call $account.testnet list_properties --accountId $account.testnet
- buy_property (buying a property)
near call $account.testnet buy_property '{"id": 0}' --accountId $account.testnet
- count_users (counting the number of users)
near call $account.testnet count_users --accountId $account.testnet
where $account.testnet represents your testnet account id`s