Skip to content

Instantly share code, notes, and snippets.

Created September 12, 2021 13:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at
//SPDX-License-Identifier: MIT
pragma solidity 0.8.3;
contract FunctionsExample {
mapping(address => uint) public balanceReceived;
address payable owner;
constructor() {
owner = payable(msg.sender);
function destroySmartContract() public {
require(msg.sender == owner, "You are not the owner");
function getOwner() public view returns(address) {
return owner;
function convertWeiToEth(uint _amount) public pure returns(uint) {
return _amount / 1 ether;
function receiveMoney() public payable {
assert(balanceReceived[msg.sender] + msg.value >= balanceReceived[msg.sender]);
balanceReceived[msg.sender] += msg.value;
function withdrawMoney(address payable _to, uint _amount) public {
require(_amount <= balanceReceived[msg.sender], "not enough funds.");
assert(balanceReceived[msg.sender] >= balanceReceived[msg.sender] - _amount);
balanceReceived[msg.sender] -= _amount;
receive() external payable {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment