The class hash is a hash chain of the definition of the class.
Classes written in Cairo are compiled into Sierra code. The Sierra code generated is an intermediate representation of the class. This new contract class is then compiled by the sequencer, via the Sierra → Casm compiler, to generate the Cairo assembly associated with this class. The resulting Casm code is then executed by the Starknet OS.
For information on how the compiler converts code from Cairo to Sierra, see Cairo and Sierra.
The elements that define a class are:
The version of the contract class object. Currently, the Starknet OS supports version 0.1.0
|Array of external functions entry points||
An entry point is a pair
|Array of L1 handlers entry points||
|Array of constructors entry points||
Currently, the compiler allows only one constructor.
A string representing the ABI of the class. The ABI hash (which affects the class hash) is given by:
An array of field elements representing the Sierra instructions.
The hash of the class is the chain hash of its components, computed as follows:
class_hash = ℎ( contract_class_version, external_entry_points, l1_handler_entry_points, constructor_entry_points, abi_hash, sierra_program_hash )
The Starknet OS currently supports contract class version 0.1.0, which is represented in the above hash computation as the ASCII encoding of the string
For more details, see the Cairo implementation.