Skip to content

Instantly share code, notes, and snippets.

@haniefhan
Created October 30, 2021 03:45
Show Gist options
  • Save haniefhan/7fea2e4f3cfdc951725e1d6adc7971dd to your computer and use it in GitHub Desktop.
Save haniefhan/7fea2e4f3cfdc951725e1d6adc7971dd to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.7;
contract SmartBank {
mapping (address => uint) public balances;
function deposit() public payable {
balances[msg.sender] = msg.value;
}
function withdraw(uint amount) public {
require(amount <= balances[msg.sender], "Your balance is not enough!");
payable(msg.sender).transfer(amount);
balances[msg.sender] -= amount;
}
function transfer(uint amount, address payable destAddr) public {
require(amount <= balances[msg.sender], "Your balance is not enough!");
balances[msg.sender] -= amount;
balances[destAddr] += amount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment