A tour of the EVM globals, carrying the constructor of the file it was copied from
Historical Significance
A tour of every global the EVM exposes to a running contract, deployed so the values could be read back from a live chain rather than reasoned about. It carries the constructor of the file it was copied out of, which is the ordinary evidence of how tutorial code actually travelled: whole files pasted and trimmed, not functions extracted.
Context
Frontier era deployment by Cyrus Adkisson, from his Solidity teaching repository.
Key Facts
Description
Returns block.coinbase, block.difficulty, block.gaslimit, block.number, block.timestamp, msg.data, msg.gas, msg.sender, msg.value, tx.gasprice, tx.origin, the contract address and its balance. It was copied from the creator balance checker chapter of cyrusadkisson/solidity-baby-steps and renamed, but the constructor was not, so creatorBalanceChecker became an ordinary public function and the contract deployed with no constructor at all. creator therefore stays at the zero address and kill, which returns true only when the caller is creator, can never fire.
Source Verified
Heuristic Analysis
The following characteristics were detected through bytecode analysis and may not be accurate.
Frontier Era
The initial release of Ethereum. A bare-bones implementation for technical users.
Bytecode Overview
Verified Source Available
Source verified through compiler archaeology and exact bytecode matching.
View Verification ProofShow source code (Solidity)
// Submitted by EthereumHistory (ethereumhistory.com)
/*
This is a demonstration of the various global variables available to contracts.
This list is probably not exhaustive, especially weeks and months from now. (9/2015)
*/
contract basicInfoGetter {
address creator;
function getCurrentBlockNumber() constant returns (uint)
{
return block.number;
}
function getBlockTimestamp() constant returns (uint) // returns current block timestamp in SECONDS (not ms) from epoch
{
return block.timestamp; // also "now" == "block.timestamp", as in "return now;"
}
function getMsgData() constant returns (bytes) // The data of a call to this function. Always returns "0xc8e7ca2e" for me.
{ // adding an input parameter would probably change it with each diff call?
return msg.data;
}
function getMsgGas() constant returns (uint) // Gas remaining on this call. Always returns 49978451 for me.
{ // Would adding an input parameter change this value?
return msg.gas;
}
function getMsgSender() constant returns (address) // Returns the address of whomever made this call
{ // (i.e. not necessarily the creator of the contract)
return msg.sender;
}
function getMsgValue() constant returns (uint) // returns amt of wei sent with this call
{
return msg.value;
}
function kill() returns (bool)
{
if (msg.sender == creator)
{
suicide(creator); // kills this contract and sends remaining funds back to creator
return true;
}
else
return false;
}
function getTxGasprice() constant returns (uint) // "gasprice" is the amount of gas the sender was *willing* to pay. 50000000 for me. (geth default)
{
return tx.gasprice;
}
function getTxOrigin() constant returns (address) // returns sender of the transaction
{ // What if there is a chain of calls? I think it returns the first sender, whoever provided the gas.
return tx.origin;
}
function getContractAddress() constant returns (address)
{
return this;
}
function getContractBalance() constant returns (uint)
{
return this.balance;
}
/**********
Standard kill() function to recover funds
**********/
function creatorBalanceChecker() public
{
creator = msg.sender;
}
function getCurrentMinerAddress() constant returns (address) // get CURRENT block miner's address,
{ // not necessarily the address of the miner when this block was born
return block.coinbase;
}
function getCurrentDifficulty() constant returns (uint)
{
return block.difficulty;
}
function getCurrentGaslimit() constant returns (uint) // the most gas that can be spent on any given transaction right now
{ // or the most gas that can be spent, globally, on each block?
return block.gaslimit;
}
}External Links
Related contracts
GetBalance
Same deployerCyrus Adkisson experimental getter (Sep 2015) exposing the ether balance of a hardcoded address via getMyBalance(). Verified byte-for-byte with soljson v0.1.1.
0x759ad4...239a87August 26, 2015Contract 0xddcd64...a08e7b
Same deployerThe greeter tutorial contract: it stores a greeting set at deployment and can be shut down by its owner.
0xddcd64...a08e7bAugust 26, 2015Contract 0x3ea0db...b922e0
Same deployerThe basic info getter from the solidity-baby-steps tutorials, a read only window onto the block and message globals.
0x3ea0db...b922e0August 31, 2015Contract 0xba575c...78733f
Same deployerA contract built to probe what the msg globals actually return, endowed with 5 ETH, deployed 1 September 2015.
0xba575c...78733fSeptember 1, 2015Contract 0x8b180c...c084df
Same deployerA third deployment of the msgExaminer that records its own creation message
0x8b180c...c084dfSeptember 1, 2015Contract 0x46dce1...3086aa
Same deployerA contract built to probe what the msg globals return, endowed with 3 ETH on 1 September 2015.
0x46dce1...3086aaSeptember 1, 2015