Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Describe contract nonce. Changed title to Contract classes and instances in contract-classes.adoc #1099

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*** xref:Accounts/simplified_transaction_flow.adoc[Simplified transaction flow]

** Contracts
*** xref:Smart_Contracts/contract-classes.adoc[Contract classes]
*** xref:Smart_Contracts/contract-classes.adoc[Contract classes and instances]
*** xref:Smart_Contracts/class-hash.adoc[Class hash]
*** xref:Smart_Contracts/contract-address.adoc[Contract address]
*** xref:Smart_Contracts/contract-storage.adoc[Contract storage]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[id="contract_classes"]
= Contract classes
= Contract classes and instances

As in object-oriented programming, Starknet distinguishes between a contract and its implementation by separating contracts into classes and instances.

== Contract Classes
== Contract classes

A _contract class_ is the definition of a contract. It includes Cairo byte code, hint information, entry point names, and everything that defines its semantics.

Each class is uniquely identified by its _class hash_, comparable to a class name in traditional object-oriented programming languages.

== Contract Instances
== Contract instances

A _contract instance_ is a deployed contract that corresponds to a class. Only contract instances act as true contracts, in that they have their own storage and can be called by transactions or other contracts.

Expand All @@ -20,7 +20,9 @@ A contract class does not necessarily have a deployed instance in Starknet.
A contract class does not necessarily require a deployed instance in Starknet.
====

== Working with Classes
#A contract instance has a nonce, the value of which is the number of transactions originating from this address plus 1. For example, when you deploy an account with a `DEPLOY_ACCOUNT` transaction, the nonce of the account contract in the transaction is `0`. After the transaction, until the account contract sends its first transaction, the nonce is `1`.#

== Working with classes

[horizontal,labelwidth=20,role="stripes-odd"]
Adding new classes:: To introduce new classes to Starknet's state, use the `DECLARE` transaction.
Expand All @@ -29,7 +31,7 @@ Deploying instances:: To deploy a new instance of a previously declared class, u

Using class functionality:: To use the functionality of a declared class without deploying an instance, use the `library_call` system call. Analogous to Ethereum's `delegatecall`, it enables you to use code in an existing class without deploying a contract instance.

== Additional Resources
== Additional resources

* xref:architecture_and_concepts:Smart_Contracts/class-hash.adoc[Class hash]
* xref:architecture_and_concepts:Network_Architecture/transactions.adoc#declare-transaction[`DECLARE` transaction]
Expand Down
Loading