Class hash
The class hash is a hash chain of the definition of the class.
Definition of a class
The elements that define a class are:
API version |
The version of the class, currently always 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. |
||
Array of used builtin names |
An ASCII-encode array, ordered by declaration. |
||
Program hash |
The starknet_keccak of the class’s program. The class’s program is the abi and program part of the
The compiler outputs abi, entrypoint selectors and the program. For program hash, |
||
Bytecode |
Represented by an array of field elements. |
How the class hash is computed
The hash of the class is the chain hash, that is, the Pedersen hash, of the above, computed as follows:
-
Start with \(h(0,\text{api_version})\).
-
For every line in the above, excluding the first, compute \(h(h(previous\_line), new\_line)\), where the hash of an array is defined as Array Hashing.
-
Let \(c\) denote the cumulative hash that results from applying the above process; the class’s hash is then \(h(c, \textrm{number_of_lines})\), where \(\text{number_of_lines}\) is 7.
For more details, see the Cairo implementation.