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.
- 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.
- Solidity
^0.8.18 - Foundry (Forge, Cast, Anvil)
- Chainlink Oracles
- MockV3Aggregator for local testing
- Forge Cheatcodes for user simulation and time manipulation
├── src/
| ├── EtherVault.sol
| └── PriceConverter.sol
├── script/
| ├── DeployEtherVault.s.sol
| ├── HelperConfig.s.sol
| └── Interact.s.sol
├── test/
| ├── mocks
| | └── MockV3Aggregator.sol
| └──TestEtherVault.t.sol
├── lib/
└── foundry.tomlRequires Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryupgit clone https://github.com/your-username/ethervault.git
cd ethervault
forge installforge buildforge test -vv
-vvgives detailed logs for easier debugging.
Start Anvil (local blockchain):
anvilDeploy the contract:
forge script script/DeployEtherVault.s.sol:DeployEtherVault --fork-url http://localhost:8545 --broadcastSet up environment variables:
export SEPOLIA_RPC_URL=your_rpc_url
export PRIVATE_KEY=your_private_keyThen deploy:
forge script script/DeployEtherVault.s.sol:DeployEtherVault --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcastforge script script/Interact.s.sol:Interact --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcastOr for local testing:
forge script script/Interact.s.sol:Interact --fork-url http://localhost:8545 --broadcastforge cleanChirag Goyal
B.Tech, Chemical Engineering, IIT Roorkee
Blockchain & Software Developer | Builder | Learner
Feel free to raise an issue or contribute improvements to this project. All contributions are welcome.