Simple Vault Contract
A basic DeFi vault that accepts ETH deposits and allows withdrawals. A basic DeFi vault that accepts ETH deposits and allows withdrawals.Explanation
This vault demonstrates core DeFi primitives: deposit, withdraw, and balance tracking. Security notes:- Uses the checks-effects-interactions pattern: state is updated before the external call.
msg.sender.call{value: amount}sends ETH safely (vs.transferwhich has gas limits).- Always validate amounts with
requirebefore state changes.
Code
Canonical knowledge ID:
code-example:simple-vault-contract