DEV Community

Cover image for DVILLA E-Commerce Project: A dApp that promotes healthy living
Chieloka Madubugwu
Chieloka Madubugwu

Posted on • Edited on

DVILLA E-Commerce Project: A dApp that promotes healthy living

This is a submission for the Build Better on Stellar: Smart Contract Challenge : Build a dApp

Table of Contents

What I Built

Dvilla Local Food Store project is a decentralised E-Commerce app where users can register an account and purchase organic foods and fruits, the app also rewards consistent users a little percentage to encourage people to stay on healthy foods and promote good living. The app leverages Stellar smart contracts to manage secure transactions, particularly in regions without credit card access, by placing assets in a vault during procurement and delivery. Payments are transferred only after safe delivery. Buyers are rest assured that payments are made or transferred to the local farms after their food items have been delivered safely to them. Its covers the Sustainability prompt and designed to fit into the category of a public goods application, where it incorporates features that contribute to real-world positive impacts. it promotes and sell products that are sustainably sourced from local farms.

Demo

The dApp is built on Next js for the frontend and Rust programming language for the backend and it incorporated the Stellar SDK for the Cli commands to interact with the blockchain and Soroban for the wallet

NOTE - To access the public url, make sure to install the Freighter wallet chrome extension. Currently, freighter wallet is unavailable for Android so download the Freighter chrome extension, create a wallet, and open the Public Url on Mac or Windows

Public Url: DVILLA E-commerce Project

Image description

My Code

The Github Repo: Github Repo

Video DEMO

smart_contract_explained

Contract on Stella Expert

Stellar Expert : Transactions done on the Contract address

The other function i implemented is the "place_order" is implemented to pay or place a cart order, it transfer the amount from the user to the contract address, then saves the order and creates a tracker that calculates the user rewards

Rust function implementation for the place_order function

Place_order_save_order

Place_order_reward tracker

Then on the frontend to sign and submit the transaction, we first need to build the transaction

Image description

Journey

For my project, I designed and implemented a smart contract on the Stellar network to facilitate seamless transactions for a local food store. The motivation behind this project was to create a decentralized application (dApp) that supports local businesses by enabling them to accept payments in XLM, thereby promoting financial inclusion and sustainability.

One of the functions which i implemented and which made me understand a lot about the concept of blockchain is the "transfer_xlm()" function. This function was used to transfer token with in place_order function and process_user_reward function

Transfer_xlm

Concepts Learned

  1. sourceAccount (--source): This is the admin that invokes the contract to do a transaction. The admin should be generated with its keyPair that is both public Key and Secret key. Its only with the secret key that a transaction is signed. Meaning the admin signs thats transaction.


  2. id or contract_id (--id): This is the address of a contract after it has been deployed. The contract_id holds all the functions of that contract. So in the case, you want to transfer a token from an address to another address. The transaction must happen on a contract having “transfer” as one of its functions. 



  3. Network (--network): This is the network on which the contracts were built or deployed on and where you will also be invoking the “transfer” transaction. This is either "testnet", "futurenet" or "mainnet".

  4. transfer_xlm: This is the name of the function in my localfoodstore contract id/address.



  5. From (--from): This is still the admin address or sourceAccount. For the transfer transaction, the admin must have a lot of XLM tokens to send to the address “to”. The address here must have been generated having its key pair (public key and secret key) and have been funded by the friendbot or another address.It’s worthy to note that if you dont have the secret key of the public address here, the transaction will fail. This can also be called Issuer address.

  6. To (--to): This holds the address to which the tokens are sent to. This address can be a contract id/address or a personal public address. This can also be called recipient address.

  7. Amount (--amount): this is the amount of tokens to be sent to the public or contract address. It can be the native XLM token or any non-native assest.

Image description

Here you can see the transfer of 1000XLM was successful to my contract address

Image description

Additional Prize Categories: Glorious Game and/or Super Sustainable

My Submission is largely under the Super Sustainable dApp category.

Next Steps

  • I hope to include feature to give the users the choice to donate their rewards to charity organisations
  • Also I will need to improve the UI

Reach me here for collaborations:
LinkedIn
Gmail
Whatsapp

Top comments (50)

Collapse
 
lief_storer_fff38ed6bd2d2 profile image
Lief Storer

This is a great dApp demo!

Where I could see this being really interesting is applying it to last-mile food delivery where users could place an order (similar to instacart) where your credit card is pre-authorized for the cart amount, but the transaction doesn't process till the food delivery is confirmed. In regions that don't have credit cards, using a smart contract to place assets in a vault while the order is being procured would be an awesome way to enable a whole economy of local buyers.

Collapse
 
chielokacodes profile image
Chieloka Madubugwu • Edited

Thanks for the Idea, i have implemented the feature. I would love to get your feedback on it. The link is same as above. Now the buyers are rest assured that payment is made only when their food items have been delivered to them

Collapse
 
chielokacodes profile image
Chieloka Madubugwu

Wow! Great idea.. I would really like upgrading the dApp with this. It provides security and trust that the food items will really get delivered safely before payments are transferred to the food store or local farm

Collapse
 
onuigbo_onyinyechi_3970ff profile image
Onuigbo Onyinyechi

What a wonderful project you've got here Chieloka.
Not only is this a brilliant blend of technology and sustainability, it also helps in promoting healthy living while supporting local farms. The rewards system is also a great idea since this will encourage consistent healthy choices. It's exciting to see how this can create real-world positive impacts.
Great job Chieloka .

Collapse
 
chielokacodes profile image
Chieloka Madubugwu

Thank you very much Onyinyechi. This is a great summary of the project, I hope to add more features to make users keep coming back, features like user can choose to donate their rewards to charity organisations

Collapse
 
kemsguy7 profile image
kemsguy7

Wonderful project, this is really encourage people to get more healthy foods

Collapse
 
chielokacodes profile image
Chieloka Madubugwu

Thank you, we are planning to add more features to get users coming back

Collapse
 
paradise profile image
Ugwu Emmanuel

Your idea is excellent. You did marvelous by incorporating a "reward for consistent users to promote good health" This shows the uniqueness of what you have created. It doesn't just make it easy for customers to order food and fruits; it also encourages them to stay healthy. Furthermore, your future plan to add a section where customers may decide to donate their rewards to charity is indeed another innovative approach to make it easy for the needy to get their own food. However, I can say you holistically considered both the customers and the less privileged.

You deserve an accolade for this bro! Keep it up.

Collapse
 
chielokacodes profile image
Chieloka Madubugwu

Wow! I thank you so much for the detailed feedback.

Collapse
 
vivian_ilechukwu_b718552e profile image
Vivian Ilechukwu

Well done, Chieloka!

Collapse
 
chieloka_madubugwu profile image
Chieloka Madubugwu

Thanks Vivian, I appreciate

Collapse
 
kelvin_smith_58f34d3b78b7 profile image
Kelvin Smith

wow nice one

Collapse
 
chibbyfx profile image
Chibuikem Nwosu

Amazing 👏

Collapse
 
stehcee profile image
Rodrick

Nice work chieloka

Collapse
 
jennifer_udeze_571a9acd2c profile image
jennifer udeze

Nice one

Collapse
 
rosemary_chideramadubugw profile image
Rosemary Chidera Madubugwu

This is really commendable. This app helps promote Sustainable Development Goals (SDGs) number 3 concerned with good health and well-being of individuals.

Collapse
 
chielokacodes profile image
Chieloka Madubugwu

Thank you very much

Some comments may only be visible to logged-in visitors. Sign in to view all comments.