Created
October 27, 2020 12:17
-
-
Save wissalHaji/43ba02467834e5d07e42fa3a1978d15c to your computer and use it in GitHub Desktop.
Balance and address checker
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: GPL-3.0 | |
pragma solidity ^0.7.0; | |
contract Checker { | |
address owner; | |
constructor() { | |
owner = msg.sender; | |
} | |
function getBalanceOfContract() public view returns(uint) { | |
return address(this).balance; | |
} | |
function getBalanceOfOwner() public view returns(uint){ | |
if(msg.sender == owner) | |
return owner.balance; | |
else return 0; | |
} | |
function getBalanceOfSender() public view returns(uint) { | |
return msg.sender.balance; | |
} | |
function getAddressOfContract() public view returns(address) { | |
return address(this); | |
} | |
function getAddressOfOwner() public view returns(address) { | |
return owner; | |
} | |
function getAddressOfSender() public view returns(address) { | |
return msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment