From 59d440b391607d0e1b6c78506d14320935d5fafd Mon Sep 17 00:00:00 2001 From: Vedant Singh Date: Wed, 16 Apr 2025 20:24:10 +0530 Subject: [PATCH] test --- simplebank.sol | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/simplebank.sol b/simplebank.sol index 455d932..9ea1e2d 100644 --- a/simplebank.sol +++ b/simplebank.sol @@ -2,52 +2,52 @@ pragma solidity ^0.8.0; contract SimpleBank { - // TODO: Declare a public variable 'owner' of type address - address public ____; + // Declare a public variable 'owner' of type address + address public owner; - // TODO: Create a mapping 'balances' that maps address to uint - mapping(address => ____) public ____; + // Create a mapping 'balances' that maps address to uint + mapping(address => uint) public balances; // Modifier to allow only owner to access certain functions modifier onlyOwner() { - // TODO: Require that msg.sender is the owner - require(msg.sender == ____, "Not the owner"); + // Require that msg.sender is the owner + require(msg.sender == owner, "Not the owner"); _; } - // TODO: Create a constructor that sets the msg.sender as owner + // Constructor that sets the msg.sender as owner constructor() { - ____ = msg.sender; + owner = msg.sender; } // Function to deposit ether into the contract function deposit() public payable { - // TODO: Increment the sender's balance with msg.value - ____[msg.sender] += ____; + // Increment the sender's balance with msg.value + balances[msg.sender] += msg.value; } // Function to check balance function getBalance() public view returns (uint) { - // TODO: Return the balance of the sender - return ____[msg.sender]; + // Return the balance of the sender + return balances[msg.sender]; } // Function to withdraw amount function withdraw(uint amount) public { - // TODO: Check if sender has enough balance - require(____[msg.sender] >= amount, "Insufficient balance"); + // Check if sender has enough balance + require(balances[msg.sender] >= amount, "Insufficient balance"); - // TODO: Deduct the amount from sender's balance - ____[msg.sender] -= amount; + // Deduct the amount from sender's balance + balances[msg.sender] -= amount; - // TODO: Transfer the amount to sender - payable(msg.sender).transfer(____); + // Transfer the amount to sender + payable(msg.sender).transfer(amount); } // Owner-only function to check contract's total balance function contractBalance() public view onlyOwner returns (uint) { - // TODO: Return address(this).balance - return ____; + // Return address(this).balance + return address(this).balance; } // Fallback function to receive ether