Skip to content

Instantly share code, notes, and snippets.

@devtosxn
Created August 3, 2022 16:54
Show Gist options
  • Save devtosxn/707540add8042aeb1834f7e8d93b762a to your computer and use it in GitHub Desktop.
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.
// 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