Skip to content

Commit a04f7d6

Browse files
authored
Quickstart refactor (#1480)
* init * cont * cont * cont * cont * typo fixes * minor fix * minor fix * cont * typo fixes * typo fixes * minor fix * minor fix * minor fix * minor fix * estevan-review * cont * finish? * minor fixes * minor fixes * minor fixes * codereview
1 parent 7588f06 commit a04f7d6

19 files changed

+761
-975
lines changed

.htaccess

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ RewriteRule ^documentation/getting_started/unit_tests/$ /quick-start/environment
900900
RewriteCond %{QUERY_STRING} ^$
901901
RewriteRule ^documentation/tools/CLI/starknet\-compiler\-options/$ /cli/starknet-compiler-options/? [R=301,L]
902902

903-
RewriteRule ^tools/starknet\-book/$ https://docs.starknet.io/? [R=301,L]
903+
RewriteRule ^tools/starknet\-book/$ / [R=301,L]
904904

905905
RewriteRule ^tools/devtools/clis/$ tools/devtools/overview? [R=301,L]
906906

@@ -922,6 +922,18 @@ RewriteRule ^tools/devtools/security/$ tools/devtools/overview? [R=301,L]
922922

923923
RewriteRule ^documentation/architecture_and_concepts/Smart_Contracts/system-calls/$ /architecture-and-concepts/smart-contracts/system-calls-cairo1/? [R=301,L]
924924

925+
RewriteRule ^/quick-start/declare-a-smart-contract/$ /quick-start/overview/? [R=301,L]
926+
927+
RewriteRule ^/quick-start/deploy-a-smart-contract/$ /quick-start/overview/? [R=301,L]
928+
929+
RewriteRule ^/quick-start/interact-with-a-smart-contract/$ /quick-start/overview/? [R=301,L]
930+
931+
RewriteRule ^/quick-start/set-up-an-account/$ /quick-start/overview/? [R=301,L]
932+
933+
RewriteRule ^/quick-start/deploy-interact-with-a-smart-contract-remix/$ /quick-start/overview/? [R=301,L]
934+
935+
RewriteRule ^/quick-start/using_devnet/$ /quick-start/devnet/? [R=301,L]
936+
925937
RewriteRule ^documentation/tools/limits_and_triggers/$ /tools/limits-and-triggers/? [R=301,L]
926938

927939
RewriteRule ^tools/limits-and-triggers/$ /chain-info/? [R=301,L]
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
About Starknet
2-
3-
* xref:index.adoc[]
4-
// * xref:notational-conventions.adoc[]
1+
* xref:index.adoc[]

components/Starknet/modules/ROOT/pages/index.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ specialized programming language.
1212
[pass]
1313
++++
1414
<div class="home-cta-container">
15-
<a href="https://docs.starknet.io/documentation/quick_start/environment_setup/" class="home-cta home-cta-first" id="cta1">
15+
<a href="/quick-start/overview/" class="home-cta home-cta-first" id="cta1">
1616
<div class="image-container">
1717
<img src="_images/developers.svg" style="filter: none; border-radius: 0px;" class="cta-image" id="img_1">
1818
</div>
@@ -21,7 +21,7 @@ specialized programming language.
2121
<p class="chakra-card__body css-jintet" id="text2"><b>Explore ></b></p>
2222
</a>
2323
24-
<a href="https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/header/" class="home-cta" id="cta2">
24+
<a href="/architecture-and-concepts/accounts/introduction/" class="home-cta" id="cta2">
2525
<div class="image-container">
2626
<img src="_images/how_SN_works.svg" style="filter: none; border-radius: 0px;" class="cta-image" id="img_2">
2727
</div>
@@ -30,7 +30,7 @@ specialized programming language.
3030
<p class="chakra-card__body css-jintet" id="text4"><b>Explore ></b></p>
3131
</a>
3232
33-
<a href="https://docs.starknet.io/documentation/starknet_versions/version_notes/" class="home-cta" id="cta3">
33+
<a href="starknet-versions/version-notes/" class="home-cta" id="cta3">
3434
<div class="image-container">
3535
<img src="_images/roadmap.svg" style="filter: none; border-radius: 0px;" class="cta-image" id="img_3">
3636
</div>
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
* Quickstart
2-
** xref:environment-setup.adoc[Setting up your environment]
3-
** xref:set-up-an-account.adoc[Setting up an account]
4-
** xref:declare-a-smart-contract.adoc[Declaring a smart contract]
5-
** xref:deploy-a-smart-contract.adoc[Deploying a smart contract]
6-
** xref:interact-with-a-smart-contract.adoc[Interacting with a smart contract]
7-
** xref:using_devnet.adoc[]
2+
** xref:quick-start:overview.adoc[Overview]
3+
** xref:quick-start:environment-setup.adoc[Setting up your environment]
4+
** xref:quick-start:compiling-hellostarknet.adoc[Compiling `HelloStarknet`]
5+
** xref:quick-start:devnet.adoc[Declaring, deploying, and interacting with `HelloStarknet` locally]
6+
** xref:quick-start:sepolia.adoc[Deploying and interacting with `HelloStarknet` on Sepolia]
7+
** xref:quick-start:next-steps.adoc[Recommended next steps]
8+
** xref:quick-start:troubleshooting.adoc[Troubleshooting]
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
= Compiling the `HelloStarknet` contract
2+
3+
== Introduction
4+
5+
Welcome to the second installment of the "Hello, Starknet!" quickstart series, the official tutorial for starting your journey as a Starknet developer! 🚀
6+
7+
Before a contract can be deployed on Starknet, its compiled code needs to be submitted to the network (also known as _declaring_ it). This installment of the series will therefore walk you though compiling Scarb's default `HelloStarknet` contract, which will be used throughout the following installments.
8+
9+
[TIP]
10+
====
11+
To learn more about Starknet smart contracts, see the xref:architecture-and-concepts:smart-contracts/contract-classes.adoc[Contracts section].
12+
====
13+
14+
== Generating `HelloStarknet`
15+
16+
Scarb's default `HelloStarknet` contract can be generated by simply running:
17+
18+
[source,terminal]
19+
----
20+
scarb new hello_starknet
21+
----
22+
23+
and selecting to set up the `Starknet Foundry (default)` test runner.
24+
25+
For the purpose of this tutorial, you can ignore all files in the `hello_starknet` directory other than `hello_starknet/src/lib.cairo`, which holds the contract's code:
26+
27+
[#example-cairo-contract]
28+
[source,cairo]
29+
----
30+
/// Interface representing `HelloContract`.
31+
/// This interface allows modification and retrieval of the contract balance.
32+
#[starknet::interface]
33+
pub trait IHelloStarknet<TContractState> {
34+
/// Increase contract balance.
35+
fn increase_balance(ref self: TContractState, amount: felt252);
36+
/// Retrieve contract balance.
37+
fn get_balance(self: @TContractState) -> felt252;
38+
}
39+
40+
/// Simple contract for managing balance.
41+
#[starknet::contract]
42+
mod HelloStarknet {
43+
use core::starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess};
44+
45+
#[storage]
46+
struct Storage {
47+
balance: felt252,
48+
}
49+
50+
#[abi(embed_v0)]
51+
impl HelloStarknetImpl of super::IHelloStarknet<ContractState> {
52+
fn increase_balance(ref self: ContractState, amount: felt252) {
53+
assert(amount != 0, 'Amount cannot be 0');
54+
self.balance.write(self.balance.read() + amount);
55+
}
56+
57+
fn get_balance(self: @ContractState) -> felt252 {
58+
self.balance.read()
59+
}
60+
}
61+
}
62+
----
63+
64+
As its comments read, this is a simple contract with two basic functions:
65+
66+
* `get_balance`, which reads the contract's current balance from storage.
67+
* `increase_balance`, which reads the contract's current balance from storage, increases it by `amount` and writes the new balance to storage.
68+
69+
== Compiling `HelloStarknet`
70+
71+
To compile the `HelloStarknet` contract, navigate into the newly created `hello_starknet` directory and run:
72+
73+
[source,terminal]
74+
----
75+
scarb build
76+
----
77+
78+
[NOTE]
79+
====
80+
The first time a project is built, some components of Scarb are compiled locally with the Rust toolchain. This process may take a few minutes, but will not happen in subsequent builds.
81+
====
82+
83+
The compiled contract should now be saved inside the `hello_starknet/target/dev/` directory as `hello_starknet_HelloStarknet.contract_class.json`.

components/Starknet/modules/quick-start/pages/declare-a-smart-contract.adoc

Lines changed: 0 additions & 162 deletions
This file was deleted.

components/Starknet/modules/quick-start/pages/deploy-a-smart-contract.adoc

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)