Created
November 15, 2022 08:39
-
-
Save DoguD/7f5ed1e8cdb984a4312709aabb5d5848 to your computer and use it in GitHub Desktop.
A simple bank smart contract.
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
// 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