Last active
February 4, 2023 17:40
-
-
Save faytey/1f30a34a3cd82b8c610b1ccb14b04771 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 | |
| ///@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