Guest User

Untitled

a guest
Nov 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. pragma solidity ^0.4.21;
  2.  
  3. contract SpecialVariables {
  4. function exec() public payable returns (
  5. address block_coinbase,
  6. uint256 block_difficulty,
  7. uint256 block_gaslimit,
  8. uint256 block_number,
  9. uint256 block_timestamp,
  10. uint256 gas_left,
  11. bytes msg_data,
  12. address msg_sender,
  13. bytes4 msg_sig,
  14. uint256 msg_value,
  15. uint256 tx_gasprice,
  16. address tx_origin
  17. ) {
  18. block_coinbase = block.coinbase; // current block miner’s address
  19. block_difficulty = block.difficulty; // current block difficulty
  20. block_gaslimit = block.gaslimit; // current block gaslimit
  21. block_number = block.number; // current block number
  22. block_timestamp = block.timestamp; // current block timestamp as seconds since unix epoch
  23. gas_left = gasleft(); // remaining gas
  24. msg_data = msg.data; // complete calldata
  25. msg_sender = msg.sender; // sender of the message (current call)
  26. msg_sig = msg.sig; // first four bytes of the calldata (i.e. function identifier)
  27. msg_value = msg.value; // number of wei sent with the message
  28. tx_gasprice = tx.gasprice; // gas price of the transaction
  29. tx_origin = tx.origin; // sender of the transaction (full call chain)
  30. }
  31.  
  32. function getBlockhash(uint256 blockNumber) public view returns (bytes32) {
  33. /// hash of the given block - only works for 256 most recent,
  34. /// excluding current, blocks - deprecated in version 0.4.22
  35. /// and replaced by blockhash(uint blockNumber).
  36. return blockhash(blockNumber);
  37. }
  38. }
Add Comment
Please, Sign In to add comment