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

chielokacodes

Chieloka Madubugwu

Posted on August 15, 2024

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

💖 💪 🙅 🚩
chielokacodes
Chieloka Madubugwu

Posted on August 15, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related