I am working on private test net. Can I get the latest transaction address inside my contract. At the basic level I am trying to have a function getLatestTransaction() which will return me the latest transaction address.

At advanced level I want to have an array containing address of all the transactions.


1 Answer 1


No, you cannot get any transaction hashes from inside a contract.

You need a function in your contract to accept transaction hashes, feed them in, and can then store them in an array. But this will cost a lot of gas to keep updated, so isn't recommended.

Related question: Is it possible to get the transaction hash from within a Solidity function call?

  • so basically there is no way I can have a function getLatestTransaction() that will return latest transaction hash?? Jul 26, 2016 at 13:11
  • Not currently. The EVM doesn't provide the transaction hash, or data such as the nonce, so a contract cannot compute the hash on its own.
    – eth
    Jul 26, 2016 at 13:22
  • But the geth console is able to display the transaction hash so they must be getting it from somewhere. If EVM doesn't provide transaction hash how is geth able to display it? Jul 26, 2016 at 13:24
  • Geth gets the transaction so it can hash it; Geth has an EVM (the EVM does not have Geth).
    – eth
    Jul 26, 2016 at 13:43
  • So how even can I have a function that accepts transaction hashes and later store them in array? I mean how that function will get Transaction hash as parameter? Jul 26, 2016 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.