Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SPDX-License-Identifier: MIT
- pragma solidity 0.8.22;
- contract Bank{
- address public accountholder;
- uint256 balance = 0;
- constructor()
- {
- accountholder = msg.sender;//one who will deploy the contract
- }
- function deposit() public payable {
- require(msg.sender==accountholder,"you are not an account holder");
- require(msg.value>0,"deposit amount should be greater than 0.");
- balance += msg.value;
- }
- function withdraw() payable public
- {
- require(msg.sender==accountholder,"you are not an account holder");
- require(balance > 0,"You dont have enough balance.");
- payable(msg.sender).transfer(balance);
- balance=0;
- }
- function showBalance() public view returns(uint)
- {
- require(msg.sender==accountholder,"you are not an account holder");
- return balance;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement