What is a hash?
Generally, a hash is the output of a hashing algorithm. A hashing algorithm in turn is an algorithm that produces a fixed-length output based on a variable length input.
Ideally, it should not be possible to figure out the input just based on the output hash. Besides that, ideally no 2 inputs result in the same output ("hash collision").
What is a transaction hash?
On Ethereum, transaction hashes are used to identify transactions on the Ethereum blockchain uniquely. Each transaction has a different hash. The transaction hash is calculated based on the transaction input/details such as the account sending the transaction, destination, value, data and nonce. Learn more about the details of Ethereum transactions here. In the following this transaction hash is referred to as "regular transaction hash".
You can look up transaction via Etherscan with a transaction hash, e.g. https://etherscan.io/tx/0x06d2fa464546e99d2147e1fc997ddb624cec9c8c5e25a050cc381ee8a384eed3.
What is a Safe transaction hash (safeTxHash)?
Similar to the regular transaction hash, the safeTxHash is used to identify a transaction of a specific Safe. It is calculated based on information such as the Safe address, the destination, Safe nonce and data. The full list can be found in the contract code.
The safeTxHash is what owners of a Safe sign in order to authorize transactions. By signing this specific hash, they implicitly authorize the transaction that resulted in this specific hash, i.e. the specific destination address, data payload etc. It is not possible that 2 different Safe transactions result in the same safeTxHash on the same network. (Technically it's not really impossible, but very very unlikely in a way that this is negligible.)
How can I find the safeTxHash for a specific transaction?
You need the full Safe transaction parameters in order to figure out the safeTxHash. It is not possible to derive the details just based on the safeTxHash.
Option 1: Open the transaction details on web. There you'll see the Ethereum transaction hash as well as the safeTxHash.
Option 2: Open your Safe in the Safe mobile app, go to transaction details and then "advanced". There you see it.
Option 3 (technical): Calculate it by calling
getTransactionHash on your Safe.
So why is there a difference between a regular transaction hash and safeTxHash?
Why not always use the regular transaction hash?
The answer is: Both fulfill different use cases.
The regular transaction hash is different depending on which account submits a transaction. Safe transactions can be submitted by any account, as long as the provided signatures are valid. This would not work if the regular transaction hash is used.
safeTxHash takes data such as gas tokens into account. This doesn't exist for a regular transaction and hence is not reflected in a regular transaction hash.
There could be multiple Safe transactions within a single Ethereum transaction, so if the regular transaction hash would be used as safeTxHash, it would not be possible to uniquely identify a Safe transaction anymore.