Skip to content

Instantly share code, notes, and snippets.

@wissalHaji
Created October 27, 2020 12:17
Show Gist options
  • Save wissalHaji/43ba02467834e5d07e42fa3a1978d15c to your computer and use it in GitHub Desktop.
Save wissalHaji/43ba02467834e5d07e42fa3a1978d15c to your computer and use it in GitHub Desktop.
Balance and address checker
// 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