Starkli

repository·master·Indexed 41 days ago

https://github.com/xjonathanlei/starkli

A high-performance CLI tool for interacting with Starknet, powered by starknet-rs. Starkli v0.4.2 provides utilities for managing accounts (supporting Argent, Braavos, and OpenZeppelin variants), declaring Sierra classes, deploying contracts via the Universal Deployer Contract, and handling EIP-2645 HD wallet paths. It features an argument resolution system to simplify inputs using schemes like addr, u256, str, const, selector, storage, and bytearray.

Tokens
16.8K
Snippets
58
Records
92
Agent score
52%

What's inside Starkli

  1. Starkli support for ETH and STRK transaction fees

    master

    Starting with release v0.4.0, Starkli switched from spec v0.7.1 to v0.8.0. Consequently, Starkli no longer supports paying fees in ETH. All transactions must use STRK for fees.

    Note for legacy requirements: If you must send pre-v3 transactions (which allow paying fees in ETH), you must use a v0.3.x Starkli release. However, it is recommended to upgrade contracts to be v3-compatible as pre-v3 transactions will eventually be disabled on the Starknet network.

  2. What are Starkli providers?

    master

    Starkli connects to the Starknet network through "providers". Currently, Starkli only supports JSON-RPC providers (the sequencer gateway has been deprecated and removed).

    Providers can be specified in two ways:

    1. Directly via a JSON-RPC URL.
    2. Through predefined networks defined in profiles.

    Important Notes:

    • Version Compatibility: Each Starkli version is tied to a specific JSON-RPC specification version. You can check your supported version using starkli -vV.
    • Default Fallback: If no provider is supplied, Starkli falls back to the sepolia network. If sepolia is not defined in your profile, it uses a free RPC vendor. It is recommended to explicitly define your network rather than relying on this fallback.
  3. Understand Starkli account variants

    master

    Starknet uses account abstraction, meaning all accounts are smart contracts. Starkli supports different "flavors" of accounts, referred to as variants. When using the starkli account command, you must specify the variant identifier to access variant-specific subcommands.

    Supported variants include:

    • argent: Argent X
    • braavos: Braavos
    • oz: OpenZeppelin
  4. How argument resolution works in Starkli

    master

    Starkli uses argument resolution to expand simple, human-readable inputs into the actual field element arguments required by the network.

    By default, arguments are parsed as raw field elements (accepting decimal or hexadecimal). To trigger the resolution process, use the format scheme:content, where scheme is a supported resolution type and content is the input for that scheme.

    This makes interacting with contracts easier by allowing you to use names, strings, or integers instead of manually calculating field elements.

  5. Configure network providers

    master

    The provider field determines how Starkli connects to the network. It can be a shorthand String or a detailed Object.

    1. RPC Provider

    Used to connect to a specific JSON-RPC endpoint URL.

    Shorthand (String): Pass the URL directly as a string.

    provider = "https://example.com/"

    Full Configuration (Object): Use an object with type = "rpc". This allows for custom HTTP headers.

    FieldMandatoryTypeDescription
    typeYesStringMust be rpc
    urlYesStringThe JSON-RPC endpoint URL
    headersNoHttpHeader[]Array of { name, value } objects

    2. Free Provider

    Used to leverage supported free RPC vendors.

    FieldMandatoryTypeDescription
    typeYesStringMust be free
    vendorYesStringMust be either blast or nethermind
    # RPC Object Example
    [default.networks.mainnet]
    chain_id = "SN_MAIN"
    provider = { type = "rpc", url = "https://example.com/", headers = [ { name = "Api-Key", value = "xxxx" } ] }
    
    # Free Vendor Example
    [default.networks.mainnet]
    chain_id = "SN_MAIN"
    provider = { type = "free", vendor = "blast" }
  6. Free RPC vendors for mainnet and sepolia

    master

    To provide a zero-setup experience, Starkli supports free RPC vendors for specific networks.

    Eligible Networks:

    • mainnet
    • sepolia

    Behavior: If you attempt to use one of these networks and it is not already defined in your active profile, Starkli will automatically use the Blast free vendor. This choice is then persisted in your profile, and all subsequent calls for that network will use the same vendor automatically.

    You can change the assigned vendor at any time by manually editing your profiles.

  7. What are Signers in Starkli

    master

    In Starkli, a signer is any entity capable of providing valid signatures for transactions. Signers are managed or created using the starkli signer command. Currently, Starkli supports three types of signers:

    1. Ledger hardware wallet: The most secure option, recommended for accounts holding significant funds.
    2. Encrypted keystores: JSON files following the Web3 secret storage definition. They require a password for creation and usage.
    3. Plain text private keys: Highly insecure; intended strictly for development purposes where security is not a priority.
  8. Understand EIP-2645 HD wallet paths

    master

    Hardware wallets like Ledger use Hierarchical Deterministic (HD) paths to derive private keys from a single seed phrase. For Starknet, the standard HD paths (e.g., m/44'/60'/0'/0/0) are not compatible with the Starknet Ledger app. Instead, you must use the EIP-2645 path format.

    A standard EIP-2645 path follows this structure: m/2645'/layer'/application'/eth_address_1'/eth_address_2'/index

    In this format, layer, application, eth_address_1, eth_address_2, and index are all 31-bit unsigned numbers.

  9. Path management best practices for Starkli

    master

    Because it is difficult to reverse-engineer which HD path corresponds to a specific public key, you must document the paths you use.

    Starkli recommends the following pattern for managing multiple accounts:

    1. Use the m//starknet'/starkli' prefix for the first 3 levels.
    2. Keep the eth_address_1 level constant at 0'.
    3. Use the eth_address_2 level as your counter: start at 0' for your first account and increment it for subsequent accounts.
    4. Keep the index level at 0.

    Why use eth_address_2 as the counter? While you could increment the index instead, incrementing eth_address_2 is safer. If you only increment the index and an attacker gains access to the xpub key at the eth_address_2 level, they could potentially compromise the entire set of keys if any single private key in that set is compromised.

  10. Use the Starkli extension for EIP-2645 paths

    master

    Because standard EIP-2645 paths require manually calculating hashes for names, Starkli provides a user-friendly extension. This extension allows you to use non-numerical strings for the layer and application segments, which Starkli automatically converts into the required 31-bit unsigned numbers.

    Note: These string-based paths are a Starkli-only extension. They will not work with other HD wallet software (like starknet-rs).

    Using non-numerical strings

    Instead of calculating hashes, you can write: m/2645'/starknet'/starkli'/0'/0'/0

    Omitting the 2645' segment

    Since Starkli exclusively uses EIP-2645 paths, you can simplify your path by leaving the first level empty: m//starknet'/starkli'/0'/0'/0

    # Example of a Starkli-style path using strings and omitting the 2645' segment
    m//starknet'/starkli'/0'/0'/0
  11. Locate the Starkli profiles file

    master

    The profiles.toml file is used to define custom networks. It is created automatically the first time you use a free RPC vendor. Depending on your operating system, the file is located at:

    • Linux and Mac: ~/.config/starkli/profiles.toml
    • Windows: %AppData%\starkli\profiles.toml