Skip to content

Instantly share code, notes, and snippets.

@faytey
Last active February 4, 2023 17:40
Show Gist options
  • Select an option

  • Save faytey/1f30a34a3cd82b8c610b1ccb14b04771 to your computer and use it in GitHub Desktop.

Select an option

Save faytey/1f30a34a3cd82b8c610b1ccb14b04771 to your computer and use it in GitHub Desktop.
//SPDX-License-Identifier: MIT
///@author Faith M. Roberts
// Write a contract that deposit fund into a contract.
// And also keep track of funds transferred into the contract.
// Add a function to the balance of address that have deposited into the contract.
//FALLBACKS
//The fallback function is executed if none of the other functions matches the function identifier or no data was provided with the function call.
pragma solidity ^0.8.0;
contract Payable {
mapping(address => uint) public balances;
address public addressOfOwner;
constructor(){
addressOfOwner = msg.sender;
}
function deposit() public payable {
balances[addressOfOwner] += msg.value;
}
function getBalance(address owner) public view returns (uint){
return balances[owner];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment