Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion build/starknet-by-example/advanced/sierra-ir.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ sierra-text = true

### Storage Variables Smart Contract Sierra Code

You can find a more complex example of the [compiled Sierra code](./sierra_ir_storage_contract) of the [Storage Variables Example](../getting-started/basics/variables#storage-variables).
You can find a more complex example of the [compiled Sierra code](./sierra_ir_storage_contract) of the [Storage Variables Example](../basic/variables#storage-variables).

## Further Reading

Expand Down
2 changes: 1 addition & 1 deletion build/starknet-by-example/applications/crowdfunding.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Crowdfunding is a method of raising capital through the collective effort of man
6. After the campaign ends, the campaign creator can claim the funds if the campaign goal is reached.
7. Otherwise, campaign did not reach it's goal, pledgers can retrieve their funds.
8. The creator can at any point cancel the campaign for whatever reason and refund all of the pledgers.
9. The contract admin can upgrade the contract implementation, refunding all of the users and resetting the campaign state (we will use this in the [Advanced Factory chapter](./advanced_factory)).
9. The contract admin can upgrade the contract implementation, refunding all of the users and resetting the campaign state (we will use this in the [Advanced Factory chapter](./advanced-factory)).

Because contract upgrades need to be able to refund all of the pledges, we need to be able to iterate over all of the pledgers and their amounts. Since iteration is not supported by `Map`, we need to create a custom storage type that will encompass pledge management. We use a component for this purpose.

Expand Down
4 changes: 2 additions & 2 deletions build/starknet-by-example/applications/simple-storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ In this example, we will use a SimpleStorage Cairo contract deployed on Starknet

The SimpleStorage contract has only one purpose: storing a number. We want the users to interact with the stored number by **writing** to the currently stored number and **reading** the number in the contract.

We will use the following SimpleStorage contract. In the [Storage Variables](../getting-started/basics/variables) page, you can find explanations for each component of the contract:
We will use the following SimpleStorage contract. In the [Storage Variables](../basic/variables) page, you can find explanations for each component of the contract:

```cairo
// [!include ~/listings/applications/simple_storage_starknetjs/src/storage.cairo:contract]
```

Because we want to interact with the get and set functions of the SimpleStorage contract using Starknet-js, we define the function signatures in `#[starknet::interface]`. The functions are defined under the macro `#[abi(embed_v0)]` where external functions are written.

Only deployed instances of the contract can be interacted with. You can refer to the [How to Deploy](../getting-started/interacting/how_to_deploy) page. Note down the address of your contract, as it is needed for the following part.
Only deployed instances of the contract can be interacted with. You can refer to the deployment documentation for more information. Note down the address of your contract, as it is needed for the following part.

## Interacting with SimpleStorage contract

Expand Down
2 changes: 1 addition & 1 deletion build/starknet-by-example/basic/components/collisions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The storage layout is only determined by the variables names, so variables with
In a future release, the `#[substorage(v1)]` will determine the storage layout based on the component as well, so collisions will be avoided.
</Note>

A good practice is to prefix the component storage variables with the component name, as shown in the [Switchable component example](./how_to).
A good practice is to prefix the component storage variables with the component name, as shown in the [Switchable component example](./intro).

#### Example

Expand Down
4 changes: 2 additions & 2 deletions build/starknet-by-example/basic/components/dependencies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Instead, we add the trait `Switchable` as a dependency to the `Countable` compon

#### Implementation of the trait in the contract

First, we import the `ISwitchable` trait defined in chapter ["Components How-To"](./how_to):
First, we import the `ISwitchable` trait defined in chapter ["Components Introduction"](./intro):

```rust
#[starknet::interface]
Expand Down Expand Up @@ -125,7 +125,7 @@ mod MockContract {

In the previous example, we implemented the `ISwitchable` trait in the contract.

We already implemented a [`Switchable`](./how_to) component that provides an implementation of the `ISwitchable` trait.
We already implemented a [`Switchable`](./intro) component that provides an implementation of the `ISwitchable` trait.
By using the `Switchable` component in a contract, we can embed the implementation of the `ISwitchable` trait in the contract and resolve the dependency on the `ISwitchable` trait.

```rust
Expand Down
2 changes: 1 addition & 1 deletion build/starknet-by-example/basic/mappings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Let's break down the key components:
- `write(key, value)`: Stores a value for a given key
- `read(key)`: Retrieves the value associated with a key
- Maps automatically initialize all values to zero
- Keys and values must be of valid storage types, see [Storing Custom Types](./storing_custom_types)
- Keys and values must be of valid storage types, see [Storing Custom Types](./storing-custom-types)

### Composite Keys

Expand Down
4 changes: 2 additions & 2 deletions build/starknet-by-example/basic/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ The storage layout of this contract is:
- Leaves 248 bits unused, 124 in each slot

<Note>
For more complex data structures, see [storing custom types](/build/starknet-by-example/getting-started/basics/storing_custom_types).
For more complex data structures, see [storing custom types](./storing-custom-types).
</Note>

<Tip>
Notice how many bits are left unused in each slot?
This can make storage operations expensive.
To optimize storage usage, you can pack multiple variables together.
Learn more in [storage optimization](../../advanced-concepts/optimisations/store_using_packing).
Learn more in [storage optimization](../advanced/store-using-packing).
</Tip>
2 changes: 1 addition & 1 deletion build/starknet-by-example/basic/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Cairo contracts support three types of variables, each serving a different purpo
- Not stored on the blockchain

2. **Storage Variables**
- Defined in the contract's [Storage](/build/starknet-by-example/getting-started/basics/storage)
- Defined in the contract's [Storage](./storage)
- Persist between contract executions
- Stored on the blockchain

Expand Down
17 changes: 17 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@
},
"contextual": {
"options": [
{
"title": "Open in Starknet Agent",
"description": "Ask questions about this page",
"icon": "user-secret",
"href": {
"base": "https://agent.starknet.io",
"query": [
{
"key": "prompt",
"value": "Read from http://docs.starknet.io$path so I can ask questions about it."
}
]
}
},
"chatgpt",
"claude",
"perplexity",
"copy",
"view"
]
Expand Down