Skip to main content

How to Calculate Transaction Hash

Transaction hash is calculated as follows:

ckbhash(molecule_encode(tx_excluding_witness))

Where:

  • ckbhash is the BLAKE2b hash algorithm specifically used in CKB. For details, refer to ckbhash.

  • molecule_encode serializes a structure into a binary format with the Molecule serialization method

  • tx_excluding_witness refers to the transaction structure excluding the witness field, i.e., a raw transaction

The definition of RawTransaction is as follows:

table RawTransaction {
version: Uint32,
cell_deps: CellDepVec,
header_deps: Byte32Vec,
inputs: CellInputVec,
outputs: CellOutputVec,
outputs_data: BytesVec,
}