Created
February 3, 2023 05:16
-
-
Save ayo-klaytn/41ccd249bb8e6af96efe0d502b2de297 to your computer and use it in GitHub Desktop.
Klaybank.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
contract KlayBank { | |
mapping(address => uint) public balances; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
} | |
function withdraw(address _recipient, uint _amount) public { | |
require(_recipient != address(0) ,"KlayBank: Cannot Send to Address Zero"); | |
require(_amount <= balances[msg.sender], "KlayBank: Insufficient Balance"); | |
balances[msg.sender] -= _amount; | |
balances[_recipient] += _amount; | |
} | |
function getBalance(address _addr) public view returns(uint) { | |
return balances[_addr]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment