# State Contract

### State Contract

StateV2.sol - Github

The State Contract stores the GIST State. The GIST State represents a snapshot of the state of all the identities operating in the system. The design of the State Contract allows identities to authenticate themselves using Identity Profiles

Every time that an identity is updated, for example when a claim is added or revoked, it needs to perform a State Transition. The output of the state transition function is a zero knowledge proof that can be verified by the State contract. The State contract verifies the proof on-chain via its transitState function.

Note that the actual proof verification is executed by calling the verifyProof function inside the verifier.sol from the transitState function inside the State Contract.

Whenever an identity is updated, the State contract updates the corresponding leaf of the GIST Tree. This process is managed by the Sparse Merkle Tree (SMT) Contract which is a Sparse Merkle Tree implementation that manages the GIST Tree and keeps track of its history.

The verifier.sol contract is automatically generated using circom and can be used as a standalone contract to verify the proof. State.sol implements further logic once the proof is verified (such as updating the GIST State).