-
Notifications
You must be signed in to change notification settings - Fork 0
ZeroNewLife/StakeBAnk
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
# 💰 StakeBank – Simple Ethereum Staking Smart Contract StakeBank is a basic staking smart contract written in Solidity. It allows users to lock ETH for 7 days and earn a fixed interest rate (default 5%). The goal is to demonstrate fundamental smart contract patterns such as staking, access control, time locks, and events. --- ## 🚀 Features - 🔐 Stake ETH with a 7-day lock period - 📈 Fixed interest (default 5%) - 🧾 Withdraw after lock time with interest - 👑 Admin function to update interest rate - 👀 View balance and unlock time - 🧠 Emits events for every deposit/withdrawal - ⚡ Written and tested on Ethereum (Remix + MetaMask) --- ## 🛠️ How to Deploy 1. Open [Remix IDE](https://remix.ethereum.org) 2. Create a new file called `StakeBank.sol` 3. Paste the contract code 4. Compile with Solidity version ^0.8.0 5. Deploy using **Injected Web3** (MetaMask) 6. Choose a network like Goerli/Sepolia or Mainnet (at your own risk) 7. Interact with contract through Remix or Web3 frontend --- ## 📄 Contract Overview ### deposit() ```solidity function deposit() external payable Allows a user to stake ETH. The deposit must be > 0. Each user can only stake once at a time. withdraw() function withdraw() external Lets a user withdraw their original deposit + interest after the 7-day lock period. increestate(uint newRate) function increestate(uint newRate) external onlyOwner Owner-only function to change the interest rate. getBalance(address user) function getBalance(address user) external view returns (uint) Returns the amount deposited by a user. getUnlockTime(address user) function getUnlockTime(address user) external view returns (uint) Returns the unlock timestamp (UNIX) for a user’s stake. receive() Contract is able to receive ETH directly (used to accept transfers if needed). Events event Deposited(address indexed user, uint amount); event Withdrawn(address indexed user, uint amount, uint interest); You can view emitted events in Remix → Terminal → Logs or through a block explorer (like Etherscan). 🔐 Access Control Only the contract owner (deployer) can update the interest rate. modifier onlyOwner { require(msg.sender == owner, "Not owner!"); _; } 💻 Example UI (optional) If you want to build a frontend, consider: React + ethers.js or viem MetaMask wallet integration Basic dashboard: balance, deposit form, withdraw button, unlock countdown 🧠 Learnings This project demonstrates: Solidity basics Mappings and structs Modifiers Safe ETH transfer Time locking logic Emitting and listening to events 👨💻 Author Developed by Zero – Web3 beginner with big plans. 📄 License MIT License Free to use, fork, and build on.
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published