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
My Code
The Github Repo: Github Repo
Video DEMO
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
Then on the frontend to sign and submit the transaction, we first need to build the 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
Concepts Learned
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.
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.
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".
transfer_xlm: This is the name of the function in my localfoodstore contract id/address.
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.
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.
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.
Here you can see the transfer of 1000XLM was successful to my contract address
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
Top comments (50)
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.
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
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
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 .
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
Wonderful project, this is really encourage people to get more healthy foods
Thank you, we are planning to add more features to get users coming back
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.
Wow! I thank you so much for the detailed feedback.
Well done, Chieloka!
Thanks Vivian, I appreciate
wow nice one
Amazing 👏
Nice work chieloka
Nice one
This is really commendable. This app helps promote Sustainable Development Goals (SDGs) number 3 concerned with good health and well-being of individuals.
Thank you very much
Some comments may only be visible to logged-in visitors. Sign in to view all comments.