Created
February 4, 2022 05:01
-
-
Save nodlAndHodl/d79ee0477df2992df88cf72edba2c520 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&runs=200&gist=
This file contains hidden or 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
pragma solidity >=0.4.24; | |
contract GlobalVariables { | |
string public lastCaller = "not-set"; | |
// Demonstrates the use of the ether subdenominations | |
function etherUnitsTest() public pure returns(bool) { | |
// True | |
bool value = (1 ether == 1000 finney); | |
return value; | |
} | |
// Demonstrates the use of the time units | |
function timeUnits() public view returns (uint) { | |
uint timeNow = now; //storing current time using now | |
//returns block time in seconds since 1970 | |
if (timeNow == 1000 days) { // converting 1000 literal to days, using the suffix days | |
return timeNow; | |
} | |
} | |
// Demonstrates the use of block object | |
function getBlockInformation() public view returns (uint number, bytes32 hash, address coinbase, uint difficulty) { | |
number = block.number; // Previous block | |
hash = blockhash(number - 1); // -1 because excluding current...same as block.blockhash() | |
// Current block | |
coinbase = block.coinbase; | |
difficulty = block.difficulty; | |
} | |
// Demonstrates the use of the msg object | |
function getMsgInformation() public view returns (bytes memory data, bytes4 sig, address sender) { | |
data = msg.data; | |
sig = msg.sig; | |
sender = msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment