Skip to content

Latest commit

Β 

History

History
161 lines (109 loc) Β· 3.35 KB

File metadata and controls

161 lines (109 loc) Β· 3.35 KB

EtherVault

EtherVault is a secure and gas-efficient Ethereum smart contract built with Solidity, designed for handling ETH deposits and withdrawals. It features robust control mechanisms like cooldowns, pausability, and an emergency withdrawal mode to protect both users and contract owners.


βœ… Features

  • Users can securely deposit ETH above a dynamically set minimum (based on Chainlink oracle price).
  • Withdrawals are only allowed after a cooldown period.
  • Owner can pause the contract in emergencies.
  • Emergency withdrawal mechanism for the owner after a set timeout.
  • Fully tested with Forge (Foundry) for deposit, withdrawal, edge cases, and access control.
  • Modular deployment and interaction scripts.
  • Oracle integration with support for mainnet, Sepolia, and local mock price feeds.

Foundry License: MIT Tests Coverage


🧰 Tech Stack

  • Solidity ^0.8.18
  • Foundry (Forge, Cast, Anvil)
  • Chainlink Oracles
  • MockV3Aggregator for local testing
  • Forge Cheatcodes for user simulation and time manipulation

πŸ“‚ Project Structure

β”œβ”€β”€ src/ 
|     β”œβ”€β”€ EtherVault.sol
|     └── PriceConverter.sol
β”œβ”€β”€ script/ 
|     β”œβ”€β”€ DeployEtherVault.s.sol
|     β”œβ”€β”€ HelperConfig.s.sol
|     └── Interact.s.sol
β”œβ”€β”€ test/ 
|     β”œβ”€β”€ mocks
|     |     └── MockV3Aggregator.sol
|     └──TestEtherVault.t.sol
β”œβ”€β”€ lib/
└── foundry.toml

πŸ› οΈ Installation

Requires Foundry

Install Foundry (if not already installed)

curl -L https://foundry.paradigm.xyz | bash
foundryup

πŸ“ Clone the Repo

git clone https://github.com/your-username/ethervault.git
cd ethervault
forge install

βš™οΈ Compile the Contracts

forge build

πŸ§ͺ Run Tests

forge test -vv

-vv gives detailed logs for easier debugging.


πŸš€ Deploy to Local Network (Anvil)

Start Anvil (local blockchain):

anvil

Deploy the contract:

forge script script/DeployEtherVault.s.sol:DeployEtherVault --fork-url http://localhost:8545 --broadcast

πŸ”— Deploy to Sepolia (or other testnets)

Set up environment variables:

export SEPOLIA_RPC_URL=your_rpc_url
export PRIVATE_KEY=your_private_key

Then deploy:

forge script script/DeployEtherVault.s.sol:DeployEtherVault --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast

πŸ’¬ Interact with the Contract

forge script script/Interact.s.sol:Interact --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast

Or for local testing:

forge script script/Interact.s.sol:Interact --fork-url http://localhost:8545 --broadcast

🧹 Clean Build Artifacts

forge clean

πŸ‘¨β€πŸ’» Author

Chirag Goyal
B.Tech, Chemical Engineering, IIT Roorkee
Blockchain & Software Developer | Builder | Learner


πŸ“¬ Feedback & Contributions

Feel free to raise an issue or contribute improvements to this project. All contributions are welcome.