Skip to content

Instantly share code, notes, and snippets.

@n1c01a5
Last active January 30, 2017 11:48
Show Gist options
  • Save n1c01a5/6be49309ed8c26b5510acfa12434e328 to your computer and use it in GitHub Desktop.
Save n1c01a5/6be49309ed8c26b5510acfa12434e328 to your computer and use it in GitHub Desktop.
#4 – get info getter smart contract on Ethereum
contract basicInfoGetter
{
address creator;
function basicInfoGetter() public
{
creator = msg.sender;
}
function getCurrentMinerAddress() constant returns (address)
{
return block.coinbase;
}
function getCurrentDifficulty() constant returns (uint)
{
return block.difficulty;
}
function getCurrentGaslimit() constant returns (uint)
{
return block.gaslimit;
}
function getCurrentBlockNumber() constant returns (uint)
{
return block.number;
}
function getBlockTimestamp() constant returns (uint)
{
return block.timestamp;
}
function getMsgData() constant returns (bytes)
{
return msg.data;
}
function getMsgSender() constant returns (address)
{
return msg.sender;
}
function getMsgValue() constant returns (uint)
{
return msg.value;
}
function getMsgGas() constant returns (uint)
{
return msg.gas;
}
function getTxGasprice() constant returns (uint)
{
return tx.gasprice;
}
function getTxOrigin() constant returns (address)
{
return tx.origin;
}
function getContractAddress() constant returns (address)
{
return this;
}
function getContractBalance() constant returns (uint)
{
return this.balance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment