Starknet Foundry

repository·master·Indexed 18 days ago

https://github.com/foundry-rs/starknet-foundry

A high-performance development toolkit for Starknet contracts written in Rust. It includes snforge, a testing framework for writing and running tests, and sncast, a CLI tool for interacting with smart contracts, sending transactions, and retrieving chain data. The toolkit is built on the native Cairo test runner and Blockifier, supporting Cairo Native execution via the --run-native flag.

Tokens
124.8K
Snippets
499
Records
678
Agent score
64%

What's inside Starknet Foundry

  1. Overview of Starknet Foundry

    master
    Starknet Foundry is a comprehensive toolchain designed for developing Starknet smart contracts. Inspired by the Ethereum Foundry, it provides a suite of tools to assist developers throughout the smart contract lifecycle, specifically for writing, deploying, and testing contracts on the Starknet network.
  2. Overview of `snforge` for Testing

    master

    snforge is the testing framework for Starknet Foundry. It allows you to:

    • Write and Run Tests: Create contract tests and execute them against a local devnet.
    • Use Cheatcodes: Manipulate the state of the VM (e.g., changing caller_address, block_timestamp, or balance) to test edge cases.
    • Test Contract Internals: Inspect storage, events, and messages sent to L1.
    • Advanced Testing: Perform Fork Testing (testing against a real network state), Fuzz Testing (randomized input testing), and Profiling (measuring resource usage).
    • Estimate Resources: Calculate gas and VM resource consumption.
  3. Overview of `sncast` for Starknet Interaction

    master

    sncast is the CLI tool used for interacting with the Starknet network and contracts. Key capabilities include:

    • Account Management: Create, import, and manage Starknet accounts.
    • Contract Lifecycle: Declare and deploy new contracts, or interact with existing ones.
    • Contract Interaction: Invoke functions (transactions) or call functions (read-only) on contracts.
    • Transaction Inspection: Perform dry runs, inspect transaction status, and verify contracts.
    • Advanced Utilities: Perform multicalls, use hardware wallets (Ledger), and transform calldata.
  4. Overview of sncast CLI

    master

    sncast is a command line tool provided by Starknet Foundry for performing Starknet RPC calls and interacting with Starknet contracts. It supports subcommands for various blockchain operations like calling functions, deploying contracts, and invoking transactions.

    Note on Accounts: Currently, sncast only supports accounts using the default signature based on the Stark curve. Some operations (e.g., declare, deploy, invoke) require paying fees and must be signed using an account.

    $ sncast <subcommand>
  5. Overview of Starknet Foundry

    master

    Starknet Foundry is a high-performance toolkit for developing Starknet contracts, written in Rust. It is built on top of the native Cairo test runner and Blockifier.

    The toolkit is composed of two primary modules:

    • snforge: A Starknet testing framework (comparable to Truffle, Hardhat, or DappTools) used for writing and running tests.
    • sncast: An all-in-one CLI tool for interacting with Starknet smart contracts, sending transactions, and retrieving chain data.

    For detailed usage, refer to the Starknet Foundry Book.

  6. Manage accounts with sncast account subcommands

    master

    The sncast account command group provides a suite of tools for managing Starknet accounts within the sncast CLI. You can use these subcommands to perform the following lifecycle operations:

    • import: Add an existing account to your local management.
    • create: Generate a new account.
    • deploy: Deploy a contract to act as an account.
    • delete: Remove an account from local management.
    • list: View all currently managed accounts.
  7. Use the `signature` module for ECDSA signatures

    master

    The signature module provides the necessary structures and traits to manage key pairs and create ECDSA signatures. It supports multiple curves:

    • signature::stark_curve: Implementation for the STARK curve.
    • signature::secp256k1_curve: Implementation for the Secp256k1 Curve.
    • signature::secp256r1_curve: Implementation for the Secp256r1 Curve.

    ⚠️ Security Warning: Cryptography in Starknet Foundry is experimental and has not been audited. Use at your own risk.

  8. Explore the `sncast` CLI Reference

    master

    The sncast CLI is the primary command-line interface for Starknet Foundry. It provides a comprehensive suite of commands for interacting with Starknet networks, managing accounts, deploying contracts, and inspecting state.

    Key command groups include:

    • Account Management: account (import, create, deploy, delete)
    • Contract Lifecycle: declare, declare-from, deploy, invoke, call
    • Multicall: multicall (new, run, execute)
    • Data Retrieval: get (balance, class-hash-at, nonce, spec-version, state-update, tx, tx-status)
    • Utilities: utils (serialize, class-hash, selector)
    • System & Config: show-config, config-path, ledger, verify, alias.