I want to keep one condition where transaction status is derived from TXhash so is there any way in where i can retrieve inside solidity smart-contract so that can get transaction status from it and check the condition. so do solidity have any function like this?



A function should not depend on transactions in the past. That's the state's job. You should never need to look back.

And, it won't work. Can a contract view the details of a transaction, given a transaction id?

Hope it helps.


No, because smart contracts live on the blockchain, which essentially is a list of transactions, or 'history'. Transactions that are not mined yet, are not part of the blockchain 'history'. That means that for a smart contract, transactions don't exist until they are executed, or mined.

To check that a transaction was mined, you will have to check the effects it has had to the state of the blockchain. You could store the hash of a transaction you need to check in a mapping(bytes32 => bool) whenever a certain function is called. That depends on what you want to do with it.

  • How would you get the hash of the transaction as mentioned in your answer?
    – heinob
    Jun 19 '18 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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