Skip to content

Instantly share code, notes, and snippets.

@Zeegaths
Created February 24, 2024 18:03
Show Gist options
  • Save Zeegaths/e614dc84783f2bcf04fb75f9998869b3 to your computer and use it in GitHub Desktop.
Save Zeegaths/e614dc84783f2bcf04fb75f9998869b3 to your computer and use it in GitHub Desktop.
// 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