Back to blog

Big quality-of-life improvements for Cairo developers

March 13, 2025

Introduction

We have heard your feedback and are actively working on addressing it!
Here are some of the most requested features for Scarb and Starknet Foundry that have just been released for Cairo developers.

One-line-installer

Setting up Scarb and Starknet Foundry can be a bit tedious: It requires setting up asdf, adding the plugins for Scarb and Starknet Foundry, and installing the latest version.

Now, all of this is replaced by a single one-liner:
curl --proto '=https' --tlsv1.2 -sSf https://sh.starkup.sh | sh
The following will:
  • Install asdf if you still don’t have it installed
  • Download the latest version of the tools
  • Set the global variables
And that’s it!
You should now have all the essential tools you need to start building, compiling, and testing Cairo contracts for Starknet.
This tool tries to capture as many edge cases as possible, but no software is perfect. If you have any issues or requests, please open a new issue on the GitHub repo.

No more Cargo for Cairo

Recent Scarb and Starknet Foundry users might have noticed that when updating to a new Starknet Foundry version, complication starts with compiling… Rust??

This wasn’t intuitive, and many users didn’t quite understand what was going on and why. Here’s a short explanation:

Why is compiling Rust necessary?

Cairo introduced support for procedural macros, which, similarly to Rust, allow developers to augment their code with macros. In Cairo, these macros are written in Rust, and then expanded to Cairo code. Starknet Foundry is using procedural macros as part of its implementation (e.g. for the #[fork] test attribute), which means that to compile a Starknet Foundry project, Rust is required to be installed.

Why is using Cargo not necessary?

The latest Starknet Foundry version introduced prebuilt plugins, which allow developers to run a prebuilt procedural macros library without compiling it locally – and therefore without the need for Cargo.

How does it work?

Cairo packages that define procedural macros (i.e. include Rust code) are prebuilt, and the procedural macros binaries are uploaded to the Cairo registry. If your code has a procedural macro dependency, its binary can be fetched from the registry without needing compile it. For security reasons, you must first specify which prebuilt macros you allow to be fetched as binaries in the allow-prebuilt-plugins configuration.

What’s in it for me?

Starting from Starknet Foundry 0.37.0, the template for Starknet Foundry projects (i.e., generated by snforge new) will have everything configured, with snforge_std configured as a trusted plugin. This means having Cargo installed is no longer needed (!), making the first compilation, CI, and onboarding much simpler.

How do I use it in my existing project?

First, you need to have:

  • Starknet Foundry 0.37.0 and up
  • Scarb 2.10.0 and up (Scarb nightly also works)

If you are creating a new project with Starknet Foundry 0.37.0 and up, you can simply use snforge new. Otherwise, specify the correct version of snforge_std in the manifest:

snforge_std= "0.37.0”

and add snforge_std to the allow list:

[tool.scarb]
allow-prebuilt-plugins = ["snforge_std"]

If everything is successful, the compilation should change from looking like this:

Removing cairo_test from dev-dependencies
Downloading snforge_std v0.37.0
Downloading snforge_scarb_plugin v0.37.0
Updating crates.io index
Locking 123 packages to latest compatible versions
Adding smol_str v0.2.2 (available: v0.3.2)
Downloading crates ...
Downloaded url v2.5.4
Downloaded serde v1.0.217
Downloaded colored v2.2.0
Downloaded serde_derive v1.0.217
Downloaded data-encoding v2.8.0
Downloaded relative-path v1.9.3
Downloaded toml_datetime v0.6.8
Downloaded utf8_iter v1.0.4
...

to looking like this:

Compiling test(no_cargo_cairo_unittest) no_cargo_cairo v0.1.0
Compiling test(no_cargo_cairo_integrationtest) no_cargo_cairo_integrationtest v0.1.0
Finished `dev` profile target(s) in 5 seconds

Tada!

Already out, but great to know

Starknet Agent will answer any of your questions

More and more developers rely on tools like ChatGPT, Sonnet, and DeepSeek to get information. Now, there is also an agent for Starknet, developed by the folks who brought you Cairo Book. Ask it anything Starknet-related, and it will fetch the latest information from the Cairo book and Starknet docs and list every reference it used.

The Starknet agent is constantly being improved to cover more documents, and is planned to offer code generation services in the near future. More info on the agent can be found in its initial announcement.

Smart arguments in sncast

Cairo types can go way beyond simple integers and contract addresses, and developers can choose a plethora of various types in a contract’s ABI, including combinations of structs, arrays, and tuple. However, CLI users might face a daunting task when calling these contracts, as each such type has its own serialization logic (after all, it’s all felts under the hood…).

sncast’s recent --arguments feature makes this is much simpler, enabling complex data structures to be invoked easily. For example, let’s look at the following function:

fn multisend(
    self: @ContractState,
    token_address: ContractAddress,
    transfer_list: Array<TransferRequest>
)

with TransferRequest defined as follows:

#[derive(Drop, Serde, Copy)]
pub struct TransferRequest {
    /// Recipient address
    pub recipient: ContractAddress,
    /// Amount to transfer
    pub amount: u256,
}

Now comes the nice part: serializing an array of structs – with one of the fields being a u256 (which is two felts) – would be a non-trivial task, but --arguments makes it easy! Simply provide the struct name as it would appear in the ABI of the contract (available in the contract_class.json file), and fill in the fields as follows:

sncast invoke \
    --contract-address 0x01bdeb4c594ea155777f45dca85352d3d90d7311ce12d15fab0a9c9fc572c90a
0x01bdeb4c594ea155777f45dca85352d3d90d7311ce12d15fab0a9c9fc572c90a \
    --function multisend \
    --arguments "
        0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d, \
        array![ \
            token_sender::token_sender::TransferRequest{ \
                recipient: 0x0065b8bb03e11b1efc0cc132d18e92c40fbf50ff2d85ffa8e609792c52a2d6e7, \
                amount: 10_u256 \
            }, \
            token_sender::token_sender::TransferRequest{ \
                recipient: 0x04884a94c414408a6ffba3b22c9f8bef9185e58ca74a79a3672f1ae035f81e54, \
                amount: 10_u256 \
            } \
        ] \
    "

Success! More information on the --arguments feature can be found in the Starknet Foundry book.

 

What are we working on now?

This is by no means the end DevX improvements for Cairo and Starknet. Here are more features that are in the works as we speak:

  • RPC 0.8 compatibility for Starknet Foundry and SDKs
  • Deal cheatcode (mint any amount of STRK to your account, on fork and non-fork tests)
  • Shell completions for sncast and snforge

So be sure to subscribe to our newsletter to stay updated with the latest news on Cairo and Starknet!