Last active
August 4, 2022 17:20
-
-
Save Jesserc/32727c6dbec1786ff5270a54de9a2465 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// SPDX-License-Identifier: MIT; | |
pragma solidity >=0.7.0 <=0.8.15; | |
contract Test { | |
mapping(address => uint256) balances; | |
function deposit() public payable { | |
require(msg.value > 0, "Input value"); | |
balances[msg.sender] += msg.value; | |
} | |
function contractBal() public view returns(uint256){ | |
return address(this).balance; | |
} | |
function returnBal() public view returns(uint256) { | |
require(balances[msg.sender] > 0, "No amount deposited"); | |
return balances[msg.sender]; | |
} | |
fallback() external payable {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment