Skip to content
S

SafeSpend

Safe-Spend: Financial Discipline, Decentralized.

Created on 25th January 2026

•

S

SafeSpend

Safe-Spend: Financial Discipline, Decentralized.

The problem SafeSpend solves

Project Description: Safe-Spend Terminal is a decentralized vault designed to manage student allowances using Ethereum smart contracts. It features a web-based terminal for students to track their balances and a Python-based monitoring agent that sends real-time alerts to Discord.

Key Features
Time-Locked Vault: Funds are mathematically locked on the blockchain until the specific unlock time is reached.

Moderated Flow: The contract enforces a 0.01 ETH allowance limit to prevent the student from draining the vault instantly.

Live Countdown: A real-time pulsing timer displays the status of the vault, showing whether it is "Locked" or "Ready".

USD Price Tracking: Integrated with the CoinGecko API to show live Ethereum balances converted to USD.

Discord Alerts: A Python agent monitors the blockchain for withdrawal events and notifies a Discord webhook immediately.

Reputation System: Tracks student financial discipline through a reputation score stored directly in the contract.

Technical Architecture

  1. Smart Contract (Solidity)

The core logic resides on the Ethereum Sepolia testnet.

Contract Address: 0x4a8e6a6aacf44dee097d6f6fddb11a72d4e00b6b.

Withdrawal Logic: Allows the student to claim the 0.01 ETH allowance once the timer hits zero.

Reputation Logic: Increments by 10 for every successful manual withdrawal.

  1. Frontend Terminal (Web3.js)

Timer Loop: Updates every second to reflect the vault's lock status.

Transaction History: Pulls the last 5 withdrawal events directly from the blockchain.

  1. Monitoring Agent (Python)

Event Listener: Specifically watches for the withdrawal event to extract the amount and remaining balance.

Discord Integration: Forwards event data to a designated Discord channel via webhook.

Setup Instructions
Frontend Setup:

Open the index.html file in any browser with MetaMask installed.

Ensure your MetaMask is set to the Sepolia Test Network.

Click "Connect Wallet" to view your balance and reputation.

Python Agent Setup:

Install dependencies using the command: pip install web3 requests.

Open the agent.py file and replace the Discord URL placeholder with your actual Discord Webhook URL.

Run the agent using the command: python agent.py.

Wisdom Library
The terminal includes a wisdom generator with financial insights such as:

Warren Buffett: "Do not save what is left after spending, but spend what is left after saving."

Benjamin Franklin: "An investment in knowledge pays the best interest."

Challenges I ran into

Building a decentralized vault like the Safe-Spend Vault involves several technical and logistical hurdles. Based on common decentralized finance (DeFi) development patterns and the specific logic of your project, here are the core challenges typically faced:

  1. The "Open Door" Problem (Time-Lock Synchronization)
    A major challenge is ensuring the vault stays "moderated" once the timer hits zero.

The Issue: In basic time-lock contracts, once the unlockTime is reached, the requirement require(block.timestamp >= unlockTime) remains true forever. This allows a student to withdraw 0.01 ETH multiple times in a row until the vault is empty, bypassing the "allowance" concept.

The Fix: You had to implement a cooldown reset inside the payout function, where every withdrawal automatically pushes the unlockTime forward by another week.

  1. Transaction Reverts & Gas Management
    Handling failed transactions (reverts) is a constant struggle in Solidity development.

Balance Sensitivity: If the user tries to withdraw but the vault has less than the ALLOWANCE (0.01 ETH), the transaction will revert. This costs the user gas (real money/test ETH) even though the transaction failed.

Automation Safety: The Chainlink Automation must be precisely programmed in checkUpkeep to only fire when the balance is sufficient, or the automation nodes will waste gas on failing transactions.

  1. Cross-Platform Integration (The "DApp Bridge")
    Synchronizing the Smart Contract, Frontend, and Python Agent requires perfect alignment of the Application Binary Interface (ABI).

The ABI Struggle: Every time you change a small detail in the Solidity code (like adding a reputationScore), the ABI changes. If you update the contract on GitHub but forget to update the JSON ABI in the Python script, the agent will "crash" or fail to recognize the new events.

Connectivity Glitches: Relying on public RPC URLs (like PublicNode or Alchemy) can lead to "Network Glitches" in your terminal or Python agent. Your agent.py had to include try/except blocks to handle these disconnects without crashing the monitoring system.

  1. Security & Exploits
    Protecting the vault from malicious activity is a high priority.

Reentrancy Risks: In DeFi, a common exploit is the "Reentrancy Attack," where an attacker triggers a withdrawal and uses a malicious "fallback" function to call the withdraw again before the contract can update its balance.

Access Control: Ensuring that only the Parent can trigger an emergency unlock and only the Student can claim the allowance requires strict require(msg.sender == ...) checks to prevent unauthorized access.

Tracks Applied (2)

Freshers

Forge Build

Discussion

Builders also viewed

See more projects on Devfolio