Created
August 3, 2022 16:54
-
-
Save devtosxn/707540add8042aeb1834f7e8d93b762a to your computer and use it in GitHub Desktop.
A simple contract that (1) deposits fund into a contract. (2) Keeps track of funds transferred into the contract.
This file contains 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.0; | |
contract MyContract { | |
address owner; | |
uint256 totalFunds; | |
mapping(address => uint256) balances; | |
constructor() public { | |
owner = msg.sender; | |
totalFunds = 0; | |
} | |
function deposit(uint256 amount) public { | |
totalFunds += amount; | |
balances[msg.sender] += amount; | |
} | |
function getBalance(address _address) public view returns (uint256) { | |
return balances[_address]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment