Full-StackProject 1 of 5
EcoHive
A green credit trading platform for a sustainable future, built around trees, water, air and mangroves. My first project, made by a team of 5 for SAP Hackfest 2024.
- Kind
- Hackathon entry
- When
- 2nd year, 2024
- With
- Team of 5
01 / The idea
EcoHive is built on green credit. Its mission is planting trees, conserving water, purifying the air and nurturing mangroves. The platform is where green credit can be held and traded.
02 / What you can do
Individuals and organisations each sign up, see a live credit balance, and send credits to each other by email.
03 / How it went
It was my first project. I built it with a team of 5 for SAP Hackfest 2024, in my second year. It reached the Top 50 out of 2000+ entries nationwide.
Code
// src/Components/Credits.jsx
export const Credits = ({ entity }) => {
const firebase = useFirebase();
const [totalCreds, setTotalCreds] = useState(0);
const getCredits = async (userId) => {
const totalCredits = await firebase.getLiveData(
`${entity}/${userId}/totalCredits`
);
// the balance updates live whenever it changes
onValue(totalCredits, (snapshot) => {
if (snapshot.exists()) setTotalCreds(snapshot.val());
});
};
useEffect(() => {
const unsubscribe = onAuthStateChanged(firebaseAuth, (user) => {
if (user) getCredits(user.uid);
});
return () => unsubscribe();
}, []);
// ...renders "Your Credits" and {totalCreds}
};