Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
📝 improve writing in chapter 2
Browse files Browse the repository at this point in the history
  • Loading branch information
omarespejel committed Apr 16, 2023
1 parent 1ce6073 commit 9b40bb1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions chapters/modules/chapter_2/pages/functions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,10 @@ In this example, the `Vote` module imports other modules like `starknet` and `ar
c. *Return values*: In Cairo, return values are declared using the `->` syntax, while Solidity uses the `returns` keyword.

2. *Modules*:
a. *Declaration*: Cairo modules are declared with the `mod` keyword, while Solidity uses the `contract` keyword to define a contract.
b. *Imports*: Cairo modules can import other modules using the `use` keyword. In Solidity, the `import` keyword is used to include external contracts or libraries.
a. *Declaration*: In Cairo, contracts are defined as modules using the `mod` keyword, while Solidity utilizes the `contract` keyword to establish a contract.
b. *Imports*: Cairo modules can import other modules with the `use` keyword, making all functions from the imported module accessible within the importing module. On the other hand, Solidity employs the `import` keyword to incorporate external contracts or libraries during compilation, and uses the `is` keyword for inheritance during contract declaration.
c. *Namespaces*: Cairo modules serve as namespaces for related functionality. In Solidity, contracts themselves act as namespaces for their functions and variables.


== Contributing

[quote, The Starknet Community]
Expand Down
9 changes: 3 additions & 6 deletions chapters/modules/chapter_2/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

As we delve into the world of Starknet, we find that the platform relies on a powerful and expressive programming language called Cairo. Designed specifically for scaling decentralized applications (dApps) using STARKs, Cairo is a Turing-complete language that enables developers to harness the power of highly efficient and scalable zero-knowledge proofs. In this chapter, we will explore Cairo in the context of Starknet. We will learn about the core concepts of Cairo, its differences from Solidity, the structure and components of Cairo smart contracts, and the unique features of the Starknet network.

By the end of this tutorial, you will have a comprehensive understanding of the fundamental concepts and components of Cairo, enabling you to build robust and efficient smart contracts on the Starknet platform.
By the end of this chapter, you will have a comprehensive understanding of the fundamental concepts and components of Cairo, enabling you to build robust and efficient smart contracts on Starknet.

== What Is a Cairo Smart Contract?

In the Starknet ecosystem, the term _smart contract_ refers to immutable computer programs that run deterministically within the context of a Starknet Operating System. These programs are written in the Cairo language and are deployed on the Starknet network, a permissionless decentralized Validity-Rollup (or ZK-Rollup) built on top of Ethereum.
In the Starknet ecosystem, the term _smart contract_ refers to immutable computer programs that run deterministically within the context of a Starknet Operating System. These programs are written in the Cairo language and are deployed on Starknet.

Let’s break down the key aspects of Cairo smart contracts:

Expand All @@ -24,12 +24,9 @@ The outcome of the execution of a Cairo smart contract is the same for everyone
Starknet Operating System context::
Cairo smart contracts operate within the context of a Starknet Operating System (Starknet OS). They can access their own state, the context of the transaction that called them, and some information about the most recent blocks.

Decentralized Starknet network::
The Starknet network is a permissionless platform, working towards its decentralization, that relies on STARK proofs for security and scalability. It operates as an L2 network over Ethereum, allowing dApps to achieve unlimited scale for their computation without compromising Ethereum's composability and security.

== Solidity vs. Cairo: Overcoming Limitations and Embracing Scalability

While Solidity is a widely adopted language for smart contract development and supports a range of applications, it is not native to provable computation. As a result, compilers that translate idiomatic Solidity code into proofs encounter several challenges:
While Solidity is a widely adopted language for smart contract development and supports a range of applications, it was not designed for provable computation. As a result, compilers that translate idiomatic Solidity code into proofs encounter several challenges:

1. Reliance on inefficient data structures, such as uint256, and operations on them
2. Mutability at the language level
Expand Down
3 changes: 3 additions & 0 deletions chapters/modules/chapter_2/pages/storage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Some similarities and differences between Cairo and Solidity in the storage impl

3. In Cairo, storage fields are accessed using specific functions such as `read` and `write` (e.g., `yes_votes::write(0_u8)`). In Solidity, storage fields are accessed using assignment and indexing (e.g., `yes_votes = 0`).

4. In Starknet, variables are stored in memory according to their name rather than according to their type or their order of declaration. Please refer to the https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-storage/[Starknet documentation] for further information.



== Contributing

Expand Down

0 comments on commit 9b40bb1

Please sign in to comment.