How to Calculate Transaction Hash
Transaction hash is calculated as follows:
ckbhash(molecule_encode(tx_excluding_witness))
Where:
-
ckbhashis the BLAKE2b hash algorithm specifically used in CKB. For details, refer to ckbhash. -
molecule_encodeserializes a structure into a binary format with the Molecule serialization method -
tx_excluding_witnessrefers 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,
}