> ## Documentation Index
> Fetch the complete documentation index at: https://docs.state.space/llms.txt
> Use this file to discover all available pages before exploring further.

# State Space CLI

The CLI allows you to deploy your contract to State Space Workbench from within your Hardhat or Foundry project.

<Accordion title="When should I use the State Space CLI?">
  **Use the CLI if any of the following apply:**\
  <Icon icon="check" iconType="solid" /> Using Foundry or Hardhat project\
  <Icon icon="check" iconType="solid" /> Using a deployment script\
  <Icon icon="check" iconType="solid" /> Multiple interoperating contracts\
  <Icon icon="check" iconType="solid" /> Large or complex codebases\
  <Icon icon="check" iconType="solid" /> Iterating and testing code changes
</Accordion>

## Install

<CodeGroup>
  ```bash Install theme={null}
  brew install state-space/state-space/cli
  ```

  ```bash Update theme={null}
  brew upgrade state-space/state-space/cli
  ```
</CodeGroup>

## Initialize project

Run the `init` command to initialize your project and create the `state-space.toml` configuration fiels.

```bash theme={null}
state-space init
```

It should look like this:

```toml state-space.toml [expandable] theme={null}
        # Sets the name of the project. 
        #
        # The project is created if it does not already exist.
        project = "Project MyToken"

        # If using State Space in a team, specify the team identifier.
        # By default, your personal account will be used.
        team = "my-team"

        # Sets the primary framework to use.
        # 
        # When setting a framework, contract sources and solc settings are 
        # automatically used when pushing code to State Space.
        # 
        # Optional. Supports "foundry" or "hardhat".
        framework = "foundry"

        # Specify paths to solc json output files.
        # If using a framework, this usually isn't necessary.
        # artifacts = []

        # Defines a deployment
        # 
        # Deployments are a set of concrete transactions and accounts. 
        # They are used as initial states when exploring your state space.
        # 
        # Deployments are recorded by running a script against a local EVM.
        # Deployments are currently only supported when using a framework.
        # [deployment.Main]

        # Command is a list of strings representing the command to run when 
        # recording this deployment. Ensure that your RPC endpoint points to
        # localhost:8545.
        # command = ["forge", "script", ...]

        # When using Foundry scripts, the scripts property may be used as a 
        # shorthand alternative to the command property.
        # The RPC url does not need to be specified when using this form.
        # scripts = [
        #    "name of or path to Foundry script", 
        # ]

        # When using Hardhat's Ignition, the modules property may be used as a 
        # shorthand alternative to the command property.
        # The RPC url does not need to be specified when using this form.
        # modules = [
        #    "path to Ignition module", 
        # ]

        # Specify the number of externally owned accounts (wallets) to use
        # in this deployment
        # accounts = 3         
```

## Configure settings

Update the settings in `state-space.toml` with your project details.

For information on additional options, see the [settings guide](/docs/cli/settings).

## Deploy &

Deploy your project to state space by running the `push` command:

```bash theme={null}
# execute command in terminal
state-space push
```

<Info>Make sure your code successfully compiles before running the `push` command.</Info>

You will be provided a link to login using your State Space credentials.

After you authenticate, the CLI will compile and deploy your code to State Space. Depending on the size of your codebase, they may take a few minutes.

Login to [State Space Workbench](https://state.space/me) and open your project from the home page.

Please [contact us](mail:contact@state.space) if you experience any issues.
