How can we search a block using transaction Id(TxID) or hash?

+1 vote
What can be the probable use case or a platform where a block is to be searched by using a transaction ID or a hash. Is there any platform where searching of a block is required??
Apr 10, 2018 in Blockchain by Christine
• 15,790 points
1,085 views

4 answers to this question.

+1 vote
Best answer

The most obvious use case would be to use it for provenance and auditability. To get the block details to check the transaction history and to get an update on the key. 

Hyperledger Fabric actually does that. In Fabric, before a block is committed and the current state of the block gets updated, the MVCC check validates if there are two concurrent transactions that exist in the same block is trying to update the same key. For that, you need to get the block for the transaction ID to understand why your transaction was invalidated. This will help you find the other transactions which tried to use the same key. like yours. Coming back to hyperledger you can use GetBlockByTxID and GetBlockByNumber exposed via QSCC so external observer would be to retrieve the block

answered Apr 10, 2018 by Johnathon
• 9,080 points

selected Aug 7, 2018 by Omkar
0 votes

You can use the following function:

$ web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])

This will return all the details of the Block. Example:

{
 "number": 3,
 "hash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
 "parentHash": "0x2302e1c0b972d00932deb5dab9eb2982f570597d9d42504c05d9c2147eaf9c88",
 "nonce": "0xfb6e1a62d119228b",
 "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
 "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
 "transactionsRoot": "0x3a1b03875115b79539e5bd33fb00d8f7b7cd61929d5a3c574f507b8acf415bee",
 "stateRoot": "0xf1133199d44695dfa8fd1bcfe424d82854b5cebef75bddd7e40ea94cda515bcb",
 "miner": "0x8888f1f195afa192cfee860698584c030f4c9db1",
 "difficulty": BigNumber,
 "totalDifficulty": BigNumber,
 "size": 616,
 "extraData": "0x",
 "gasLimit": 3141592,
 "gasUsed": 21662,
 "timestamp": 1429287689,
 "transactions": [
   "0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
 ],
 "uncles": []
}
*/
answered Apr 26 by Shirish
0 votes

You can use the curl command. But this will work only if the node is running locally. 

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x200100", true],"id":1}' http://localhost:8545

answered Apr 26 by John
0 votes

If the Blockchain you want to know is online, then you can use this: https://www.blockchain.com/explorer

If it's a private blockchain, then you will have to use it locally. You can download it here: https://github.com/hyperledger/blockchain-explorer

answered Apr 26 by Esha

Related Questions In Blockchain

+1 vote
1 answer

How can I initiate a transaction on ethereum private network using mobile device?

There is no android wallet to connect ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,350 points
64 views
0 votes
1 answer

How can we decrypt a transaction payload when confidentiality is on?

You can try the following: you can only ...READ MORE

answered May 2, 2018 in Blockchain by Shashank
• 10,350 points
77 views
0 votes
1 answer
0 votes
1 answer

Can we protect a Private Blockchain with a Public Blockchain and how?

I have recently reviewed Exonum framework (https://exonum.com/) ...READ MORE

answered Jun 19, 2018 in Blockchain by Perry
• 17,020 points
38 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 26,550 points
83 views
+1 vote
1 answer
0 votes
1 answer
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,080 points
87 views