Skip to content

Instantly share code, notes, and snippets.

@Jesserc
Last active August 4, 2022 17:20
Show Gist options
  • Save Jesserc/32727c6dbec1786ff5270a54de9a2465 to your computer and use it in GitHub Desktop.
Save Jesserc/32727c6dbec1786ff5270a54de9a2465 to your computer and use it in GitHub Desktop.
// 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