Skip to content

Instantly share code, notes, and snippets.

@DoguD
Created November 15, 2022 08:39
Show Gist options
  • Save DoguD/7f5ed1e8cdb984a4312709aabb5d5848 to your computer and use it in GitHub Desktop.
Save DoguD/7f5ed1e8cdb984a4312709aabb5d5848 to your computer and use it in GitHub Desktop.
A simple bank smart contract.
// contracts/Version1-Safe.sol
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address from, address to, uint256 value) external returns(bool);
function transfer(address to, uint256 value) external returns(bool);
}
contract Bank {
mapping(address => uint256) public depositAmount;
function deposit(uint256 amount) public {
IERC20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56).transferFrom(msg.sender, address(this), amount);
depositAmount[msg.sender] += amount;
}
function withdraw() public {
IERC20(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56).transfer(msg.sender, depositAmount[msg.sender]);
depositAmount[msg.sender] = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment