Can a contract view the details of a transaction, given a transaction id?
More generally, what details of the blockchain is a given contract aware of?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityCan a contract view the details of a transaction, given a transaction id?
More generally, what details of the blockchain is a given contract aware of?
No, a contract only has access to the current state of the blockchain, and transactions are not part of state.
Specifically, these functions are available in Solidity for examining the current state:
block.coinbase (address): current block miner’s address
block.difficulty (uint): current block difficulty
block.gaslimit (uint): current block gaslimit
block.number (uint): current block number
block.blockhash (function(uint) returns (bytes32)): hash of the given
block - only works for 256 most recent blocks
block.timestamp (uint): current block timestamp
msg.data (bytes): complete calldata
msg.gas (uint): remaining gas
msg.sender (address): sender of the message (current call)
msg.value (uint): number of wei sent with the message
now (uint): current block timestamp (alias for block.timestamp)
tx.gasprice (uint): gas price of the transaction
tx.origin (address): sender of the transaction (full call chain)
<address>.balance: balance of the address in Wei
<address>.send(uint256) returns (bool): send given amount of Wei to address, returns false on failure.