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

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

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. 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

To access the public url, make sure to install the Freighter wallet chrome extension

Public Url: https://stellar-ecommerce-project.vercel.app/

My Code

The Github Repo: https://github.com/ChielokaCode/stellar_ecommerce_project

I have also included a video demo of the dApp, the functions I implemented and the result in the Cli using Stella Cli commands to interact with the blockchain through the terminal

smart_contract_explained

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

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

Place_order_transaction

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

These are the 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: 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: 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: 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.

Additional Prize Categories: Glorious Game and/or Super Sustainable

My Submission is largely under the super sustainable dApp category

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
how-to-identify-different-work-styles-for-better-productivity

How to Identify Different Work Styles for Better Productivity

Next Post
gemma-explained:-an-overview-of-gemma-model-family-architectures

Gemma explained: An overview of Gemma model family architectures

Related Posts