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

Add install Scarb via asdf #338

Merged
merged 4 commits into from
Mar 1, 2024
Merged
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
4 changes: 2 additions & 2 deletions src/ch00-00-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Here are some of them:
Cairo is tailor-made for creating STARK-based smart contracts. As
Starknet’s native language, it’s central to building scalable and secure
decentralized apps. To start learning now, check out the [Cairo
Book](https://cairo-book.github.io/) and
Book](https://book.cairo-lang.org/) and
[Starklings](https://github.com/shramee/starklings-cairo1).

Inspired by Rust, Cairo lets you write contracts safely and
Expand Down Expand Up @@ -141,7 +141,7 @@ SNIPs serve three crucial roles:
view of how Starknet has evolved.

Because SNIPs are stored as text files in a [version-controlled
repository](https://github.com/starknet-io/SNIPs), you can easily track
repository](https://github.com/starknet-io/SNIPs/tree/main/SNIPS), you can easily track
changes and understand the history of proposals.

For those who are building on Starknet, SNIPs aren’t just
Expand Down
4 changes: 2 additions & 2 deletions src/ch01-00-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ You can monitor transaction hashes and addresses using any Starknet block explor

- [Starkscan](https://testnet.starkscan.co/)
- [Voyager](https://goerli.voyager.online/)
- [ViewBlock](https://viewblock.io.starknet/)
- [ViewBlock](https://viewblock.io/starknet)
- [oklink](https://www.oklink.com/starknet)

These tools provide a visual representation of transactions and contract state alterations. Notably, when you alter the contract ownership using the `transfer_ownership` function, the event emitted by the contract appears in the block explorer. It's an effective method to track contract events.
Expand All @@ -336,4 +336,4 @@ Decide your direction from the following choices:

1. **Deepen Your Starknet Knowledge**: For an extensive grasp of Starknet's inner workings and potential use cases, delve into Chapter 3 of the Starknet Book. This chapter details Starknet’s architectural nuances. Then go ahead from there.

2. **Dive into Cairo**: If you're more attuned to coding and wish to craft Starknet contracts, then Cairo is essential. It stands as Starknet's core contract language. Begin with Chapters 1-6 of the [Cairo Book](https://book.cairo-lang.org/title-page.html), ranging from basics in _Getting Started_ to more advanced aspects such as _Enums and Pattern Matching_. Conclude by navigating to the [Starknet Smart Contracts chapter](https://book.cairo-lang.org/ch99-00-starknet-smart-contracts.html), ensuring you have a well-rounded understanding.
2. **Dive into Cairo**: If you're more attuned to coding and wish to craft Starknet contracts, then Cairo is essential. It stands as Starknet's core contract language. Begin with Chapters 1-6 of the [Cairo Book](https://book.cairo-lang.org/title-page.html), ranging from basics in _Getting Started_ to more advanced aspects such as _Enums and Pattern Matching_. Conclude by navigating to the [Starknet Smart Contracts chapter](https://book.cairo-lang.org/ch12-00-introduction-to-starknet-smart-contracts.html), ensuring you have a well-rounded understanding.
2 changes: 1 addition & 1 deletion src/ch02-00-starknet-tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ In this chapter, you’ll explore:
- **Frameworks:** Build using Starknet-Foundry

- **SDKs:** Discover multi-language support through Starknet.js,
Starknet-rs, Starknet_py, and Caigo
Starknet-rs, Starknet_py, and Cairo

- **Front-end Development:** Use Starknet.js and React

Expand Down
54 changes: 47 additions & 7 deletions src/ch02-01-basic-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,64 @@ To upgrade Starkli, simply repeat the steps.

## Scarb Package Manager Installation

We will get deeper into Scarb later in this chapter. For now, we will go over the installation process.
Scarb is also Cairo's package manager and is heavily inspired by [Cargo](https://doc.rust-lang.org/cargo/),
Rust’s build system and package manager.

For macOS and Linux:
Scarb handles a lot of tasks for you, such as building your code (either pure Cairo or Starknet contracts),
downloading the libraries your code depends on, building those libraries.

### Requirements

Scarb requires a Git executable to be available in the `PATH` environment variable.

### Installation

To install Scarb, please refer to the [installation instructions](https://docs.swmansion.com/scarb/download).
We strongly recommend that you install
Scarb [via asdf](https://docs.swmansion.com/scarb/download.html#install-via-asdf), a CLI tool that can manage
multiple language runtime versions on a per-project basis.
This will ensure that the version of Scarb you use to work on a project always matches the one defined in the
project settings, avoiding problems related to version mismatches.

Please refer to the [asdf documentation](https://asdf-vm.com/guide/getting-started.html) to install all
prerequisites.

Once you have asdf installed locally, you can download Scarb plugin with the following command:

```bash
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh
asdf plugin add scarb
```

For Windows, follow manual setup in the [Scarb
documentation](https://docs.swmansion.com/scarb/download.html#windows).
This will allow you to download specific versions:

```bash
asdf install scarb 2.5.4
```

Restart the terminal and run:
and set a global version:

```bash
asdf global scarb 2.5.4
```

Otherwise, you can simply run the following command in your terminal, and follow the onscreen instructions. This
will install the latest stable release of Scarb.

```bash
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh
```

- In both cases, you can verify installation by running the following command in a new terminal session, it should print both Scarb and Cairo language versions, e.g:

```bash
scarb --version
scarb 2.5.4 (28dee92c8 2024-02-14)
cairo: 2.5.4 (https://crates.io/crates/cairo-lang-compiler/2.5.4)
sierra: 1.4.0
```

To upgrade Scarb, rerun the installation command.
For Windows, follow manual setup in the [Scarb
documentation](https://docs.swmansion.com/scarb/download.html#windows).

## Katana Node Installation

Expand Down
8 changes: 4 additions & 4 deletions src/ch02-03-scarb.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ language is advised. We suggest reading chapters 1-6 of the [Cairo
Book](https://book.cairo-lang.org/title-page.html), covering topics from
_Getting Started_ to _Enums and Pattern Matching._ Follow this by
studying the [Starknet Smart Contracts
chapter](https://book.cairo-lang.org/ch99-00-starknet-smart-contracts.html)
chapter](https://book.cairo-lang.org/ch12-00-introduction-to-starknet-smart-contracts.html)
in the same book. With this background, you’ll be well-equipped to
understand the examples presented here.

Expand Down Expand Up @@ -34,7 +34,7 @@ streamlined.
# Installation

Scarb is cross-platform, supporting macOS, Linux, and Windows. For
installation, refer to the [Basic installation guide](./ch02-01-basic-installation.html).
installation, refer to the [Basic installation guide](./ch02-01-basic-installation.html#scarb-package-manager-installation).

# Cairo Project Structure

Expand Down Expand Up @@ -348,11 +348,11 @@ mod ownable_contract {

Basically we decided to apply `components` on the section related to `ownership` and created a separated module `ownable_component`. Then we kept the `data` section in our main module `ownable_contract`.

To get the full implementation of this project, navigate to the `src/` directory in the [examples/Ownable-Components](https://github.com/starknet-edu/starknetbook/examples/Ownable-Components) directory of the Starknet Book repo. The `src/lib.cairo` file contains the contract to practice with.
To get the full implementation of this project, navigate to the `src/` directory in the [examples/Ownable-Components](https://github.com/starknet-edu/starknetbook/tree/main/examples/Ownable-Starknet) directory of the Starknet Book repo. The `src/lib.cairo` file contains the contract to practice with.

After you get the full code on your machine, open your terminal, input `scarb build` to compile it, deploy your contract and call functions.

You can learn more about components in [Chapter 12 of The Cairo Book](https://book.cairo-lang.org/ch99-01-05-00-components.html).
You can learn more about components in [Chapter 16 of The Cairo Book](https://book.cairo-lang.org/ch15-02-composability-and-components.html?highlight=ownable%20componen#example-an-ownable-component).

Scarb is a versatile tool, and this is just the beginning of what you
can achieve with it. As you gain more experience in the Cairo language
Expand Down
16 changes: 8 additions & 8 deletions src/ch02-05-testnet-deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This chapter guides developers through the process of compiling, deploying, and interacting with a Starknet smart contract written in Cairo on the testnet. Earlier, the focus was on deploying contracts using a local node, Katana. This time, the deployment and interaction target the Starknet testnet.

Ensure the following commands run successfully on your system. If not, see the [Basic Installation](ch02-01-basic-installation.md) section:
Ensure the following commands run successfully on your system. If not, see the [Basic Installation](./ch02-01-basic-installation.md) section:

```bash
scarb --version # For Cairo code compilation
Expand All @@ -17,7 +17,7 @@ the Account Descriptor is a JSON file detailing the wallet’s address and
public key.

In order for an account to be used as a signer it must be deployed to the appropriate network,
Starknet Goerli, Sepolia or mainnet, and funded. For this example we are going to use Goerli Testnet. To deploy your wallet, visit [Smart Wallet Setup](https://book.starknet.io/ch01-00-getting-started.html#smart-wallet-setup).
Starknet Goerli, Sepolia or mainnet, and funded. For this example we are going to use Goerli Testnet. To deploy your wallet, visit [Smart Wallet Setup](./ch01-00-getting-started.html#smart-wallet-setup).
Now you’re ready to interact with Starknet smart contracts.

### Creating a Signer
Expand Down Expand Up @@ -188,8 +188,8 @@ There are three main options for RPC providers, sorted by ease of use:
documentation](https://docs.infura.io/networks/starknet/how-to/choose-a-network).

2. **Your Own Node**: For those who want full control. It’s the most
complex but offers the most freedom. Check out [Chapter 4 of the
Starknet Book](https://book.starknet.io/chapter_4/node.html) or
complex but offers the most freedom. Check out [Chapter 3 of the
Starknet Book](./ch03-00-architecture.html#nodes) or
[Kasar](https://www.kasar.io/) for setup guides.

3. **Free RPC vendor**: These 3 networks are eligible for free RPC vendors: mainet, goerli, sepolia.
Expand Down Expand Up @@ -232,7 +232,7 @@ Note: Here we used the Public RPC Endpoint v0.6 Starknet (Goerli) Testnet from *
>
> ⚠️ And if you use Goerli, make sure you use it in subsequent commands as well.

After this process, search your wallet address on the Starknet explorer. To see the details, go back to [Smart Wallet Setup](https://book.starknet.io/ch01-00-getting-started.html#smart-wallet-setup).
After this process, search your wallet address on the Starknet explorer. To see the details, go back to [Smart Wallet Setup](./ch01-00-getting-started.html#smart-wallet-setup).

After running the command, you’ll see a message like the one below.
We’re using a Braavos wallet as an example, but the steps are the same
Expand Down Expand Up @@ -306,7 +306,7 @@ of the Starknet Book repo. The `src/lib.cairo` file contains a basic
contract to practice with.

First, compile the contract using the Scarb compiler. If you haven’t
installed Scarb, follow the installation guide in the [basic installation](./ch02-01-basic-installation)
installed Scarb, follow the installation guide in the [basic installation](./ch02-01-basic-installation.html#scarb-package-manager-installation)
section.

```bash
Expand Down Expand Up @@ -372,8 +372,8 @@ main components:
2. Any constructor arguments that the contract expects.

In our example, the constructor expects an _owner_ address. You can
learn more about constructors in [Chapter 12 of The Cairo
Book](https://book.cairo-lang.org/ch99-01-03-02-contract-functions.html?highlight=constructor#1-constructors).
learn more about constructors in [Chapter 13 of The Cairo
Book](https://book.cairo-lang.org/ch13-02-contract-functions.html).

The command would look like this:

Expand Down
4 changes: 2 additions & 2 deletions src/ch02-06-starkli.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In the next subchapter we will create a short Bash script using Starkli to query

## Basic Setup

To ensure a smooth start with Starkli, execute the following command on your system. If you encounter any issues, refer to the [Basic Installation](ch02-01-basic-installation.md) guide for assistance:
To ensure a smooth start with Starkli, execute the following command on your system. If you encounter any issues, refer to the [Basic Installation](./ch02-01-basic-installation.md) guide for assistance:

```bash
starkli --version # Verifies Starkli installation and interacts with Starknet
Expand Down Expand Up @@ -54,7 +54,7 @@ The output will be:
0
```

Since katana is a temporary local node and its state is ephemeral, the block number is initially 0. Refer to [Introduction to Starkli, Scarb and Katana](ch02-02-starkli-scarb-katana.md) for further details on changing the state of Katana and observing the block number after commands like starkli declare and starkli deploy.
Since katana is a temporary local node and its state is ephemeral, the block number is initially 0. Refer to [Introduction to Starkli, Scarb and Katana](./ch02-02-starkli-scarb-katana.md) for further details on changing the state of Katana and observing the block number after commands like starkli declare and starkli deploy.

To declare a contract, execute:

Expand Down
4 changes: 2 additions & 2 deletions src/ch02-09-01-counter-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For a visual walkthrough, do check out the [Basecamp frontend session](https://d

- [Reactjs](https://react.dev/learn/start-a-new-react-project): A frontend building framework.
- [@argent/get-starknet](https://www.npmjs.com/package/@argent/get-starknet): A wrapper for **[starknet.js](https://github.com/0xs34n/starknet.js)**, aiding interaction with wallet extensions.
- [starknet](https://www.npmjs.com/package/starknet): A JavaScript library for Starknet.
- [Starknet](https://www.npmjs.com/package/starknet): A JavaScript library for Starknet.

## Setting Up the Environment

Expand Down Expand Up @@ -234,4 +234,4 @@ Here's a quick recap:
- Adjust the counter value (increment or decrement)
- Fetch data from the blockchain

For a visual walkthrough, do check out the [Basecamp frontend session](https://drive.google.com/file/d/1Dtb3Ol_BVoNV4w-_MKV8aeyyRra8nRtz/view). This comprehensive session delves deeper into the nuances of the concepts we've touched upon, presenting a mix of theoretical explanations and hands-on demonstrations.
For a visual walkthrough, do check out the [Basecamp VII: S5 Frontend](https://drive.google.com/file/d/1Dtb3Ol_BVoNV4w-_MKV8aeyyRra8nRtz/view). This comprehensive session delves deeper into the nuances of the concepts we've touched upon, presenting a mix of theoretical explanations and hands-on demonstrations.
2 changes: 1 addition & 1 deletion src/ch02-09-starknet-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ With Starknet.js, you can also automate the process of deploying a smart contrac

# Deployment of Smart Contracts using Starknet.js

Starknet.js offers capabilities for deploying smart contracts. In this tutorial, we demonstrate this by deploying an account contract, which we previously developed in [Chapter 4](https://book.starknet.io/ch04-03-standard-account.html), through a scripted approach.
Starknet.js offers capabilities for deploying smart contracts. In this tutorial, we demonstrate this by deploying an account contract, which we previously developed in [Chapter 4](./ch04-03-standard-account.html), through a scripted approach.

## STEP 1: Initial Setup and Dependency Installation

Expand Down
2 changes: 1 addition & 1 deletion src/ch02-14-security-considerations.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ mod StoreSecretPassword {

<img alt="deploy" src="img/ch02-sec_priv01.png" class="center" style="width: 75%;" />

However, understanding Cairo's [storage layout](https://book.cairo-lang.org/ch99-01-03-01-contract-storage.html?highlight=kecc#storage-addresses), we can create a script to read the stored variable:
However, understanding Cairo's [storage layout](https://book.cairo-lang.org/ch13-01-contract-storage.html), we can create a script to read the stored variable:

```javascript
import { Provider, hash } from "starknet";
Expand Down
4 changes: 2 additions & 2 deletions src/ch02-15-01-cairo-fuzzer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Cairo-fuzzer
# Cairo-Fuzzer

[Cairo-fuzzer](https://github.com/FuzzingLabs/cairo-fuzzer) is a tool designed for smart contract developers to assess security. It operates both independently and as a library.
[Cairo-Fuzzer](https://github.com/FuzzingLabs/cairo-fuzzer) is a tool designed for smart contract developers to assess security. It operates both independently and as a library.

## Features

Expand Down
2 changes: 1 addition & 1 deletion src/ch03-02-sequencers.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sequencers

Before diving in, make sure to check out the ["Architecture"](ch03-00-architecture.md) chapter for a
Before diving in, make sure to check out the [Architecture](./ch03-00-architecture.md) chapter for a
quick exploration of Starknet’s sequencers, provers and nodes.

Three main layers exist in blockchain: data availability, ordering, and
Expand Down
6 changes: 3 additions & 3 deletions src/ch03-04-01-pathfinder-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Total estimated cost: Approximately $550.

## Running Pathfinder Node Using Docker

For those who prefer a self-managed setup of all dependencies, refer to the comprehensive [Installation from Source](doc/install-from-source.md) guide.
For those who prefer a self-managed setup of all dependencies, refer to the comprehensive [Installation from Source](https://github.com/eqlabs/pathfinder/blob/main/doc/install-from-source.md) guide.

### Prerequisites

Expand Down Expand Up @@ -259,9 +259,9 @@ The `path` of the URL used to access the JSON-RPC server determines which versio

Note that the pathfinder extension is versioned separately from the Starknet specification itself.

### pathfinder extension API
### Pathfinder extension API

You can find the API specification [here](doc/rpc/pathfinder_rpc_api.json).
You can find the API specification [here](https://github.com/eqlabs/pathfinder/blob/main/doc/rpc/pathfinder_rpc_api.json).

## Monitoring API

Expand Down
4 changes: 2 additions & 2 deletions src/ch03-08-01-deploymet-and-interaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ In this section we will be focussing on declaring, deploying and interacting wit

To declare and deploy the piggy bank contract, it’s required that you have the following available; don't worry, we’ll point you to resources or links to get them sorted out.

1. Starkli: Starkli is a CLI tool that connects us to the Starknet blockchain. Installation steps can be found [here](ch02-02-starkli-scarb-katana.md).
1. Starkli: Starkli is a CLI tool that connects us to the Starknet blockchain. Installation steps can be found [here](./ch02-02-starkli-scarb-katana.md).

2. Starknet testnet RPC: You need your personalized gateway to access the starknet network. Starkli utilizes this API gateway to communicate with the starknet network: you can get one from Blast [here](https://blastapi.io/public-api/starknet).

3. Deployer Account: To interact with the starknet network via Starkli, you need a cli account/ wallet. You can easily set that up by going through [this page](ch04-03-deploy-hello-account.md).
3. Deployer Account: To interact with the starknet network via Starkli, you need a cli account/ wallet. You can easily set that up by going through [this page](./ch04-02-hello-account.html).

4. Sufficient gas fees to cover the declaration and deployment steps: you can get starknet Sepolia Eth either by bridging your Sepolia Eth on Ethereum to Starknet [here](https://www.yetanotherswap.com/bridge).

Expand Down
2 changes: 1 addition & 1 deletion src/ch04-02-hello-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To check your current Scarb version, run:
scarb --version
```

To install or update Scarb, refer to the Basic Installation instructions in Chapter 2, covering macOS and Linux environments:
To install or update Scarb, refer to the Basic Installation instructions in [Chapter 2](./ch02-01-basic-installation.html#scarb-package-manager-installation), covering macOS and Linux environments:

```bash
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh
Expand Down
2 changes: 1 addition & 1 deletion src/ch04-03-01-deploy-standard-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

After building our account contract, we'll now deploy it using Starkli on the testnet and interact with other contracts.

Ensure you've installed [starkli](https://github.com/xJonathanLEI/starkli) and [scarb](https://docs.swmansion.com/scarb/download.html). Review the Basic Installation subchapter in Chapter 2 if you haven't.
Ensure you've installed [starkli](https://github.com/xJonathanLEI/starkli) and [scarb](https://docs.swmansion.com/scarb/download.html). Review the Basic Installation subchapter in [Chapter 2](./ch02-01-basic-installation.html#scarb-package-manager-installation) if you haven't.

## Account Contract Configuration Files

Expand Down
Loading
Loading