> For the complete documentation index, see [llms.txt](https://docs.bonsol.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bonsol.org/developers/setup-a-local-environment.md).

# Setup a local environment

## Requirements

:bulb: In this section, you'll be running a local Bonsol proving node. Currently provers are limited to running on x86\_64-linux systems due to dependencies on [STARK-to-SNARK](https://bonsol.gitbook.io/docs/core-concepts/introduction#stark-to-snark-conversion) tooling. We're looking for workarounds for MacOS, but in the meantime we suggest developing on a remote Linux machine.

Before you begin, ensure you have the following system requirements:

* [Rust](https://solana.com/docs/intro/installation#install-rust)
* [Solana CLI](https://solana.com/docs/intro/installation#install-the-solana-cli)
* [pnpm/pnpx](https://pnpm.io/installation)

Verify you have these requirements by running:

```bash
cargo --version
rustc --version
solana --version
pnpm --version
```

## Local environment setup

{% stepper %}
{% step %}
**Clone the repository**

```bash
git clone https://github.com/bonsol-collective/bonsol
cd bonsol
```

{% endstep %}

{% step %}
**Install the RISC Zero prover**

```bash
# Install the prover to the default location (current directory)
./bin/install_prover.sh

# Or specify a custom installation location
./bin/install_prover.sh --prefix /path/to/install
```

{% endstep %}

{% step %}
**Run the setup script**

* Checks that the STARK verification tools are installed
* Generates and parses the verification key for on-chain use

```bash
# Set up local environment
./bin/setup.sh

# Or specify a custom installation prefix if you used one for install_prover.sh
./bin/setup.sh --prefix /path/to/install
```

{% endstep %}

{% step %}
**Run the Solana validator script**

* Builds the Solana BPF programs using `cargo build-sbf`
* Starts a local Solana validator with the Bonsol program at address `BoNsHRcyLLNdtnoDf8hiCNZpyehMC4FDMxs6NTxFi3ew`
* Includes a callback example program
* Allows adding additional BPF programs with their addresses

```bash
# Start a local validator
./bin/validator.sh

# Or run the local validator with the reset option
./bin/validator.sh -r
```

{% endstep %}

{% step %}
**Run the Bonfire Coordinator**

* Starts Elasticsearch (via Docker) for persistent log storage
* Automatically generates TLS certificates in certs/ if missing
* Starts the coordination server for Node communication

```bash
# Start Bonfire
./bin/run-bonfire.sh
```

{% endstep %}

{% step %}
**Run a local Bonsol node**

* Creates a new node keypair if one doesn't exist
* Airdrop SOL to the node keypair for transaction fees
* Run the Bonsol node with the appropriate hardware acceleration:
  * Linux: CPU or CUDA (if `-F cuda` flag is used)

```bash
# Start a node with default CPU configuration
./bin/run-node.sh

# For Linux systems with CUDA support
./bin/run-node.sh -F cuda
```

{% endstep %}
{% endstepper %}

## Troubleshooting

* If the prover installation fails, check your internet connection and try increasing the `--job-timeout` value.
  * `--job-timeout`: Set timeout for download operations in seconds (default: 3600)

```bash
# Install the prover with an increased timeout
./bin/install_prover.sh --job-timeout 7200
```

* If the validator fails to start, ensure that Rust and Solana CLI tools are properly installed
* For node startup issues, verify that the validator is running and that SOL was successfully airdropped to your node keypair


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.bonsol.org/developers/setup-a-local-environment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
