This is a submission for the Build Better on Stellar: Smart Contract Challenge : Build a dApp
What I Built
Our project, the Animal Welfare Dapp, is designed to facilitate donations for animal feeding through a decentralized platform. The app allows users to create and manage donation posts, where Feeders can list their needs for feeding animals, and Donors can contribute funds to these posts. By leveraging Stellar smart contracts, our app ensures transparency and security when managing donations and posts.
Demo
https://animal-welfare-app.vercel.app/
You can sent donation directly
My Code
Set Up Environment / Project Installation Guide
A) Environment Setup:
-
Install Rust, using command
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Install the Soroban CLI using below mentioned command. For more info visit => Soroban docs
cargo install --locked soroban-cli
-
Install Node.js
-
Get the Freighter Wallet extension for you browser. Once enabled, then got to the network section and connect your wallet to the testnet.
-
Install wasm32-unknown-unknown package using command:
rustup target add wasm32-unknown-unknown
-
To configure your CLI to interact with Testnet, run the following command:
soroban network add \
--global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Network ; September 2015"
-
In order to deploy the smartcontract you will need an account. You can either use the an account from the
Freighter Wallet
or can configure an account namedalice
in the testnet using the commandsoroban keys generate --global alice --network testnet
-
You canβ¦
You can check minimal transaction fee through below URL
https://stellar.expert/explorer/testnet/account/GBXEE2WQVDPCQDYWJKDEHPHCFLBIG33IGQQI2AQ47XJ4SZ46BKAEB7BV
where GBXEE2WQVDPCQDYWJKDEHPHCFLBIG33IGQQI2AQ47XJ4SZ46BKAEB7BV is public key
Journey
Implementation and Smart Contract Design
Smart Contract Design:
The core of our implementation is a Stellar smart contract written in Rust, using the soroban-sdk
. The contract includes several key functionalities:
-
Post Management:
-
add_post
: Allows Feeders to create new posts, including details such as title, description, wallet address, and donation goals. -
delete_post
: Permits the deletion of posts if needed. -
update_post
: Enables updates to existing posts, including changing the title and description. -
get_posts
: Retrieves all posts available in the system. -
view_post_by_id
: Fetches a specific post by its ID.
-
-
Donation Management:
-
donate
: Allows Donors to contribute funds to a feeder post.
-
Motivation:
The motivation behind this project is to create a transparent and user-friendly platform for animal welfare. By using Stellar smart contracts, we aim to provide a decentralized solution that ensures the integrity of donation data and the proper management of posts.
Learning Experience:
Working with Stellar's smart contracts and the soroban-sdk
has been a valuable learning experience. It provided insights into Rust programming for blockchain applications and the intricacies of smart contract development on Stellar. We gained hands-on experience in handling data storage, managing state, and implementing secure donation mechanisms.
Pride Points:
We are particularly proud of the following aspects of our project:
- Transparency: The use of smart contracts ensures that all interactions (posts and donations) are recorded and immutable, providing complete transparency.
- Ease of Use: The intuitive design of the app and the straightforward interaction with the smart contract make it easy for both Feeders and Donors to use.
- Error Handling and Logging: Comprehensive error handling and detailed logging help maintain the contract's reliability and make debugging easier.
Next Steps
In the future, we hope to expand the functionality of the app by adding features such as:
- Advanced Analytics: Provide Feeders with analytics on donation trends and donor engagement.
- Enhanced User Interface: Improve the UI/UX to make the app more engaging and accessible.
Invoking the Smart Contract
Certainly! Here are the commands to invoke the functions from the new smart contract:
- Create Post
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- create_post --title "Feed the Cats" --description "Donation to feed stray cats" --amount_requested 500 --image_url "https://example.com/cat_food.jpg" --feeder_address "GA3F45EXAMPLEWALLET"
- Get Post By ID
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- get_post_by_id --post_id 1
- Update Post
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- update_post --post_id 1 --new_title "Feed the Kittens" --new_description "Updated donation for feeding kittens" --new_amount_requested 600 --new_image_url "https://example.com/kitten_food.jpg" --deactivate false
- Get All Posts
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- get_all_posts
- Delete Post
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- delete_post --post_id 1
- Permanently Delete Post
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- delete_post_permanently --post_id 1
- Donate
stellar contract invoke --id YOUR_CONTRACT_ID --network testnet --source YOUR_KEYNAME -- donate --post_id 1 --amount 100
Explanation:
- YOUR_CONTRACT_ID: Replace with the actual ID of your deployed contract.
- YOUR_KEYNAME: Replace with the key name configured for your source account.
-
testnet: Indicates that the command is executed on the Stellar testnet. Change to
mainnet
if you're working on the main network. - Method-Specific Flags: The parameters after the method name correspond to the arguments the function expects.
- Ensure that all data types provided match the expected types in the smart contract methods. For strings and URLs, enclose them in quotes.
Feel free to reach out if you have any questions or need further assistance with the project!
Top comments (0)