Skip to content

Instantly share code, notes, and snippets.

@ayo-klaytn
Created February 3, 2023 05:16
Show Gist options
  • Save ayo-klaytn/41ccd249bb8e6af96efe0d502b2de297 to your computer and use it in GitHub Desktop.
Save ayo-klaytn/41ccd249bb8e6af96efe0d502b2de297 to your computer and use it in GitHub Desktop.
Klaybank.sol
// 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