diff --git a/README.md b/README.md index a9a3ef4..2994577 100644 --- a/README.md +++ b/README.md @@ -1 +1,222 @@ -# thrive + **Thrive is a staking dApp built with Clarity and WalletConnect**. + +# πŸͺ™ Stacks Staking dApp (Clarity + WalletConnect) + +A decentralized staking application built on **Stacks**, using **Clarity smart contracts** and **WalletConnect** for secure wallet interactions. +The app allows users to stake STX, earn rewards, and unstake β€” all through a clean, connected web interface. + +--- + +## πŸš€ Overview + +This project demonstrates a **full-stack staking dApp** on Stacks using: + +* **Clarity (v4)** for the smart contract +* **WalletConnect** for wallet authentication & transaction signing +* **React** for the frontend +* **Node.js** for backend utilities (optional) + +The focus is on **clarity, correctness, and real-world usability** rather than complex DeFi mechanics. + +--- + +## ✨ Features + +* πŸ” Wallet connection via **WalletConnect** +* πŸ’° Stake STX into a smart contract +* πŸ” Unstake and receive rewards +* πŸ“‘ On-chain event tracking using `print` +* ⚑ Real-time UI updates +* 🧩 Clean, modular architecture + +--- + +## πŸ—οΈ Architecture Overview + +``` +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Frontend β”‚ ← React + WalletConnect +β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Stacks RPC β”‚ ← Transaction submission +β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ + β”‚ + β–Ό +β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” +β”‚ Smart Contractβ”‚ ← Clarity (staking logic) +β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ +``` + +Optional (for analytics / live updates): + +``` +Smart Contract β†’ Chainhooks β†’ Backend β†’ Frontend +``` + +--- + +## πŸ“ Project Structure + +``` +. +β”œβ”€β”€ contracts/ +β”‚ └── staking.clar +β”‚ +β”œβ”€β”€ frontend/ +β”‚ β”œβ”€β”€ src/ +β”‚ β”‚ β”œβ”€β”€ App.jsx +β”‚ β”‚ β”œβ”€β”€ wallet.js +β”‚ β”‚ └── api.js +β”‚ └── index.html +β”‚ +β”œβ”€β”€ backend/ (optional) +β”‚ └── server.js +β”‚ +└── README.md +``` + +--- + +## 🧠 Smart Contract Overview + +### Core Capabilities + +* Accepts STX deposits +* Tracks user stake balances +* Issues rewards on unstake +* Emits structured events for off-chain tracking + +### Example Event Emission + +```clarity +(print { + event: "stake", + user: tx-sender, + amount: amount, + block: block-height +}) +``` + +### Key Properties + +* Written in **Clarity 4** +* Deterministic and auditable +* No admin privileges +* No hidden state changes + +--- + +## πŸ” Wallet Integration (WalletConnect) + +The frontend uses **WalletConnect** to: + +* Connect users’ Stacks wallets (e.g., Leather) +* Request transaction signatures +* Submit contract calls securely + +### Supported Actions + +* Connect / Disconnect wallet +* Stake STX +* Unstake STX +* Read on-chain balances + +--- + +## πŸ–₯ Frontend Functionality + +### UI Features + +* Wallet connection status +* Stake input field +* Stake / Unstake buttons +* Display of recent staking activity +* Live refresh from on-chain data + +### Data Flow + +``` +User β†’ WalletConnect β†’ Stacks Network β†’ Contract + ↓ + UI Refresh +``` + +--- + +## πŸ§ͺ Local Development + +### Prerequisites + +* Node.js β‰₯ 18 +* Clarinet +* Stacks Wallet (Leather recommended) + +--- + +### 1️⃣ Run the Smart Contract + +```bash +clarinet check +clarinet console +``` + +--- + +### 2️⃣ Run the Frontend + +```bash +cd frontend +npm install +npm run dev +``` + +--- + +### 3️⃣ Connect Wallet + +* Open browser +* Connect via WalletConnect +* Approve transactions in wallet + +--- + +## πŸ”’ Security Notes + +* This project is for **educational/demo purposes** +* No audits have been performed +* Rewards are paid from contract balance +* No slashing or lock-up mechanisms +* Do not use with real funds without review + +--- + +## πŸ“ˆ Possible Enhancements + +* Time-based staking rewards +* SIP-010 token staking +* Persistent backend storage +* WebSocket event streaming +* Multi-wallet support +* Governance voting + +--- + +## πŸ“„ License + +MIT License β€” free to use, modify, and distribute. + +--- + +## βœ… Summary + +This project demonstrates how to: + +βœ” Build a Clarity smart contract +βœ” Connect wallets securely using WalletConnect +βœ” Stake and unstake STX +βœ” React to on-chain events +βœ” Build a clean, user-facing dApp + +