CryptoBank

View on GitHub


CryptoBank is a Solidity smart contract that acts as an on-chain Ether bank. Users can deposit ETH, withdraw their balance, and send ETH directly to other addresses — all guarded against reentrancy attacks. The contract owner can adjust the maximum deposit limit at any time.

Built using Foundry as part of a Solidity security and smart contract development workflow.

Architecture

CryptoBank Contract Architecture

Functions

FunctionAccessDescription
depositEther()PublicDeposit ETH into the bank; updates Balances[msg.sender]
withdrawEther(amount)PublicWithdraw ETH to caller; protected with nonReentrant
sendEth(amount, to)PublicTransfer ETH to another address; protected with nonReentrant
modifyMaxLimit(n)OwnerUpdate the depositLimit state variable

State Variables & Events

NameTypeDescription
Balancesmapping(address => uint)Tracks each user’s ETH balance
depositLimituintMaximum ETH a user can deposit
EventEmitted When
EtherDepositedSuccessful deposit
EtherWithdrawnSuccessful withdrawal
EtherSentSuccessful peer-to-peer transfer
MaxBalanceEditedOwner changes the deposit limit

Security

  • withdrawEther and sendEth use a nonReentrant modifier to prevent reentrancy attacks.
  • Balance checks are performed before any ETH transfer.
  • Owner-only access control is applied to administrative functions.