Created
February 24, 2024 18:03
-
-
Save Zeegaths/e614dc84783f2bcf04fb75f9998869b3 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.8.24; | |
contract DepositFunds { | |
//track the balance | |
mapping(address => uint) deposits; | |
//deposit function | |
function deposit(uint _amount) external payable { | |
require (msg.value >= _amount, "Insuffient funds"); | |
require(msg.sender != address(0), "address = zero"); | |
payable(address(this)).transfer(_amount); | |
deposits[msg.sender] = deposits[msg.sender] + _amount; | |
} | |
//get balance | |
function getBalance(address _address) external view returns (uint){ | |
return deposits[_address]; | |
} | |
receive() external payable { } | |
fallback() external payable { } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment