What’s inside the Block in Hyperledger Fabric?

In this article, I’ll try to demonstrate a BlockReader application written Go programming language that extracts the various segments of a block structure in Hyperledger Fabric.

Image for post
Image for post


BlockReader application extract and showcase the complete data structure of a Block that contains several transactions. The application will require a transaction id to query the ledger to retrieve the associated block. Then the application will follow the Block data structure to read the content of the Block.


What’s inside the Block

There are three sections of a Block that store transaction information in the ledger.


The header consist of Block number, copy of the previous block hash and the current block hash


The Data fields of a block are the essentials segment that contents the transaction details sorted in the byte array. We’ll extract hidden elements of the Data byte array in the course of this article.


The MetaData fields contain the created time of the block, certificate details and signature of the block writer.


The transaction is stored inside the envelope containing the transaction payload and sorted by the Ordering Service. The extraction process starts from the Envelope struct.

Get Envelope from BlockData


The Payload struct contains the ChannelHeader and SignatureHeader as Header fields.

Get Payload from Envelope

Payload Header


It contains the basic channel information and chaincode info.

Get the ChannelHeader from the Payload


This structure contains the Creator details that holds Mspid, identity certificate for the member service provider. The Creator field is the marshalled object of msp.SerializedIdentity.

Get SignatureHeader from the Payload

Get Creator from SignatureHeader

Extracting Identity Certificate for the MSP

Payload Data

The Data field of the Payload contains the transaction details for the Block. And the TransactionAction structure holds Header and Payload that follows Signature Header for the submitted transaction and ChainCodeActionPayload containing the Chaincode invoked arguments, type of chaincode and the read/write set for the ChaincodeEndorseTransaction.


Header: It’s similar to the earlier SignatureHeader containing the identities details for submitting the transaction.

Payload: It is the Marshalled object of ChainCodeActionPayload that contains various Chaincode actions performed during a transaction.



It contains the Chaincode Input elements used during the transaction

Input: It is the marshalled object of ChaincodeInvocationSpec
TransientMap: It’s content quite sensitive data related to application-level confidentiality. The details are always removed from the transaction and never gets updated in the ledger.


It contents the chaincode information and the arguments used during the invocation.


It is the marshalled object of ChaincodeEndorsedAction struct that content the Proposal Hash and the Read/Write set used for the Chaincode in the transaction.

Read/Write Set

The Extension field is the marshalled object of ChaincodeAction that contains the Read and Write operation set performed for the transaction.

Results: It’s the marshalled object of TxReadWriteSet struct that contains read/write set, Block Range info and the metadata.

So, this is the overview of extracting the Block data structure for a transaction id and understanding the core elements use cases. Please check the BlockReader application at Github and share your feedback.

I hope you find this article useful :)


Written by

Working on various software development projects, [Android, Go, Blockchain, Node.js, MongoDB, JavaScript, Kubernetes, Docker]

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store