TransactionHashDeclareV2
Calculates the transaction hash for a Declare V2 transaction using the deprecated Pedersen-based hash calculation.
Function Signature
func TransactionHashDeclareV2(
txn *rpc.DeclareTxnV2,
chainID *felt.Felt,
) (*felt.Felt, error)Parameters
txn- The Declare V2 transaction containing:Version- Transaction version stringSenderAddress- Address of the account declaring the classClassHash- Hash of the Sierra contract classCompiledClassHash- Hash of the compiled (CASM) classMaxFee- Maximum fee willing to payNonce- Account nonce
chainID- The Starknet chain ID
Returns
*felt.Felt- The calculated transaction hasherror- Error if required parameters are missing
Description
This function calculates the transaction hash for deprecated Declare V2 transactions. V2 introduced the compiled class hash for Cairo 1.0 contracts. It uses the Pedersen hash algorithm and is maintained for compatibility with historical transactions. Internally calls CalculateDeprecatedTransactionHashCommon.
Specification
Follows the V2 Declare hash calculation specification.
Related Functions
- TransactionHashDeclareV1 - V1 variant without compiled class hash
- TransactionHashDeclareV3 - Current V3 standard
- CompiledClassHash - Calculate compiled class hashes

