INVOKE v3
Transaction fields
Hash calculation
TheINVOKE v3 transaction hash is calculated as a Poseidon hash over the given transaction elements, specifically:
-
invokeis a constant prefix string, encoded in ASCII. -
chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain ID. -
proof_factsare included in the hash computation only when present; otherwise, they are omitted. -
l1_gas_boundsis constructed as follows: -
l2_gas_boundsis constructed as follows: -
l1_data_gas_boundsis constructed as follows: -
data_availability_modesis a concatenation offee_data_availability_modeandnonce_data_availability_mode, as follows: -
his the Poseidon hash.
DECLARE v3
The DECLARE transaction introduces new contract classes into the state of Starknet, enabling other contracts to deploy instances of those classes or use them in a library call. For more information, see the Cairo Book.
Transaction fields
Hash calculation
The hash of a v3DECLARE transaction is computed as follows:
-
declareis a constant prefix string, encoded in ASCII. -
chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain ID. -
l1_gas_boundsis constructed as follows: -
l2_gas_boundsis constructed as follows: -
l1_data_gas_boundsis constructed as follows: -
data_availability_modesis a concatenation offee_data_availability_modeandnonce_data_availability_mode, as follows: -
his the Poseidon hash. -
class_hashis the hash of the contract class. See the Cairo Book] for details about how the hash is computed -
compiled_class_hashis the hash of the compiled class generated by the Sierra→Casm compiler that is used in Starknet
DEPLOY_ACCOUNT v3
Since StarkNet v0.10.1 the DEPLOY_ACCOUNT transaction replaces the DEPLOY transaction for deploying account contracts.
To use it, you should first pre-fund your new account address so that you can pay the transaction fee. You can then send the DEPLOY_ACCOUNT transaction.
For more information, see Deploying a new account.
Transaction fields
Hash calculation
The hash of aDEPLOY_ACCOUNT transaction is computed as follows:
-
deploy_accountis a constant prefix string, encoded in ASCII. -
chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain ID. -
l1_gas_boundsis constructed as follows: -
l2_gas_boundsis constructed as follows: -
l1_data_gas_boundsis constructed as follows: -
data_availability_modesis a concatenation offee_data_availability_modeandnonce_data_availability_mode, as follows: -
his the Poseidon hash. -
class_hashis the hash of the contract class hash. See the Cairo Book for details about how the hash is computed. -
contract_addressis the address of the newly deployed account. For information on how this address is calculated, see the Cairo Book.
Additional information
Signature
While Starknet does not have a specific signature scheme built into the protocol, the Cairo language, in which smart contracts are written, does have an efficient implementation for ECDSA signature with respect to a STARK-friendly curve. For more information, see Cryptography.Chain ID
Chain IDs are given as numbers, representing the ASCII encoding of specific constant strings, as illustrated by the following Python snippet:SN_MAINfor Starknet’s main network.SN_SEPOLIAfor Starknet’s public testnet on Sepolia.
Legacy information
INVOKE v1
Transaction fields
Hash calculation
TheINVOKE v1 transaction hash is calculated as a hash over the given transaction elements, specifically:
invokeis a constant prefix string, encoded in ASCII.- The placeholder zero is used to align the hash computation for the different types of transactions.
chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain-Id.his the Pedersen hash
INVOKE v0
Hash calculation
The hash of a v0INVOKE transaction is computed as follows:
invokeis a constant prefix string, encoded in (ASCII).chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain-Id. v2 and v3his the Pedersen hash
DECLARE v2
Transaction fields
Hash calculation
The hash of a v2DECLARE transaction is computed as follows:
his the Poseidon hash functionclass_hashis the hash of the contract class. See the Cairo Book for details about how the hash is computedcompiled_class_hashis the hash of the compiled class generated by the Sierra→Casm compiler that is used in Starknet
DECLARE v1
Transaction fields
The
DECLARE v1 transaction was used to declare Cairo 0 classes.Hash calculation
The hash of a v1DECLARE transaction is computed as follows:
declareis a constant prefix string, encoded in ASCII.class_hashis the hash of the contract class. See the Cairo Book for details about how the hash is computed.- The placeholder zero is used to align the hash computation for the different types of transactions.
chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain ID.his the Pedersen hash
DECLARE v0
Hash calculation
The
DECLARE v0 transaction used to declare Cairo 0 classes.DECLARE transaction is computed as follows:
declareis a constant prefix string, encoded in ASCII.- The placeholder zeros are used to align the hash computation for the different types of transactions.
his the Pedersen hashchain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain-Id.class_hashis the hash of the contract class. See the Cairo Book for details about how the hash is computed.
DEPLOY_ACCOUNT v1
Transaction fields
Hash calculation
The hash of aDEPLOY_ACCOUNT transaction is computed as follows:
deploy_accountis a constant prefix string, encoded in ASCII.- The placeholder zero is used to align the hash computation for the different types of transactions.
his the Pedersen hashchain_idis a constant value that specifies the network to which this transaction is sent. For more information, see [chain-id].class_hashis the hash of the contract class. See the Cairo Book for details about how the hash is computed.
DEPLOY v0
Hash calculation
If you need to retrieve the hash of an existingDEPLOY transaction, you can use this information to calculate the hash of the transaction.
Before you can calculate the transaction hash, get the deployed contract address. The DEPLOY transaction’s hash is calculated as shown in the following pseudo code:
- The placeholder zero is used to align the hash computation for the different types of transactions.
deployandconstructorare constant strings encoded in ASCII.his the Pedersen hash andsn_keccakis Starknet Keccak.chain_idis a constant value that specifies the network to which this transaction is sent. For more information, see Chain ID.contract_addressis calculated as described see the Cairo Book.