Created
August 30, 2022 03:54
-
-
Save depresto/5e7833c65c783f397a6c5362402f7c0a to your computer and use it in GitHub Desktop.
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
pragma solidity 0.8.7; | |
contract Vault { | |
mapping(address => uint256) public accountBalance; | |
function withdraw(uint256 amount) public { | |
uint256 currentBalance = accountBalance[msg.sender]; | |
require(amount <= currentBalance, "Account balance is not enough"); | |
accountBalance[msg.sender] -= amount; | |
payable(msg.sender).transfer(amount); | |
} | |
function deposit() public payable { | |
accountBalance[msg.sender] += msg.value; | |
} | |
receive() external payable { | |
accountBalance[msg.sender] += msg.value; | |
} | |
fallback() external payable { | |
accountBalance[msg.sender] += msg.value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment