> ## Documentation Index
> Fetch the complete documentation index at: https://magicblock-42-crank.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Development

> Run and test your Native Rust or Anchor programs with full customization on your local host and Ephemeral Rollups minimizing network latency and rate limit risk.

***

### Quick Access

Explore program and test scripts for both Anchor and Native Rust:

<CardGroup cols={2}>
  <Card title="GitHub" icon="anchor" href="/pages/ephemeral-rollups-ers/how-to-guide/quickstart" iconType="duotone">
    Anchor Implementation
  </Card>

  <Card title="GitHub" icon="rust" href="/pages/ephemeral-rollups-ers/how-to-guide/rust-program" iconType="duotone">
    Native Rust Implementation
  </Card>
</CardGroup>

***

### Local Environment

> ⚠️ When using a local ER validator, you need to connect it to your preferred base layer (e.g., `mainnet-beta`, `devnet`, or `localhost`) where the accounts are delegated.

<Note>
  <p>
    These public validators are supported for development. Make sure to add the
    specific ER validator account when delegating:
  </p>

  <ul>
    <li>
      Asia (devnet-as.magicblock.app):{" "}
      <code>MAS1Dt9qreoRMQ14YQuhg8UTZMMzDdKhmkZMECCzk57</code>
    </li>

    <li>
      EU (devnet-eu.magicblock.app):{" "}
      <code>MEUGGrYPxKk17hCr7wpT6s8dtNokZj5U2L57vjYMS8e</code>
    </li>

    <li>
      US (devnet-us.magicblock.app):{" "}
      <code>MUS3hc9TCw4cGC12vHNoYcCGzJG1txjgQLZWVoeNHNd</code>
    </li>

    <li>
      TEE (tee.magicblock.app):{" "}
      <code>FnE6VJT5QNZdedZPnCoLsARgBwoE6DeJNjBs2H1gySXA</code>
    </li>

    <li>
      Local ER (localhost):{" "}
      <code>mAGicPQYBMvcYveUZA5F5UNNwyHvfYh5xkLS2Fr1mev</code>
    </li>
  </ul>
</Note>

<Tabs>
  <Tab title="solana-test-validator (localhost)">
    <Steps>
      <Step title="Set up Solana Test Validator (Localhost) and deploy your upgraded program">
        1. Install `solana-test-validator`:

        ```bash theme={null}
        sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
        ```

        2. Install the latest MagicBlock Ephemeral Validator:

        ```bash theme={null}
        npm install -g @magicblock-labs/ephemeral-validator@latest
        ```

        2. Run `solana-test-validator` with cloned delegation program and accounts from Devnet:

        ```bash theme={null}
        mb-test-validator --reset
        ```

        3. Upgrade and deploy your program to localhost:

        <Tabs>
          <Tab title="Rust Native">
            ```bash theme={null}
            cargo build-sbf
            solana config set --url localhost
            solana program deploy YOUR_PROGRAM_PATH
            ```
          </Tab>

          <Tab title="Anchor">
            ```bash theme={null}
            anchor build && anchor deploy \
            --provider.cluster localnet
            ```
          </Tab>
        </Tabs>
      </Step>

      <Step title="Run MagicBlock ER validator (Localhost)">
        Run the local ephemeral validator pointing to localhost:

        ```bash theme={null}
        RUST_LOG=info ephemeral-validator \
          --accounts-lifecycle ephemeral \
          --remote-cluster development \
          --remote-url http://127.0.0.1:8899 \
          --remote-ws-url ws://127.0.0.1:8900 \
          --rpc-port 7799
        ```
      </Step>

      <Step title="Test program instructions and delegation (Localhost)">
        Run your tests against the local ephemeral validator:

        <Tabs>
          <Tab title="Rust Native">
            ```bash theme={null}
            EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
            EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
            PROVIDER_ENDPOINT=http://localhost:8899 \
            WS_ENDPOINT=ws://localhost:8900 \
            yarn test
            ```
          </Tab>

          <Tab title="Anchor">
            ```bash theme={null}
            EPHEMERAL_PROVIDER_ENDPOINT="http://localhost:7799" \
            EPHEMERAL_WS_ENDPOINT="ws://localhost:7800" \
            anchor test \
            --provider.cluster localnet \
            --skip-local-validator \
            --skip-build \
            --skip-deploy
            ```
          </Tab>
        </Tabs>
      </Step>
    </Steps>
  </Tab>

  <Tab title="devnet">
    <Steps>
      <Step title="Upgrade and deploy program on Devnet">
        Upgrade your program with MagicBlock delegation and deploy it to Devnet:

        <Tabs>
          <Tab title="Rust Native">
            ```bash theme={null}
            cargo build-sbf
            solana config set --url devnet
            solana program deploy YOUR_PROGRAM_PATH
            ```
          </Tab>

          <Tab title="Anchor">
            ```bash theme={null}
            anchor build && anchor deploy \
            --provider.cluster devnet
            ```
          </Tab>
        </Tabs>
      </Step>

      <Step title="Install and run MagicBlock ER validator (Devnet)">
        1. Install the latest MagicBlock Ephemeral Validator:

        ```bash theme={null}
        npm install -g @magicblock-labs/ephemeral-validator@latest
        ```

        2. Run the local ephemeral validator pointing to Devnet:

        ```bash theme={null}
        RUST_LOG=info ephemeral-validator \
          --accounts-lifecycle ephemeral \
          --remote-url "https://rpc.magicblock.app/devnet" \
          --rpc-port 7799
        ```
      </Step>

      <Step title="Test program instructions and delegation (Devnet)">
        Run your tests against the local ephemeral validator:

        <Tabs>
          <Tab title="Rust Native">
            ```bash theme={null}
            EPHEMERAL_PROVIDER_ENDPOINT=http://localhost:7799 \
            EPHEMERAL_WS_ENDPOINT=ws://localhost:7800 \
            yarn test
            ```
          </Tab>

          <Tab title="Anchor">
            ```bash theme={null}
            EPHEMERAL_PROVIDER_ENDPOINT="http://localhost:7799" \
            EPHEMERAL_WS_ENDPOINT="ws://localhost:7800" \
            anchor test \
            --provider.cluster devnet \
            --skip-local-validator \
            --skip-build \
            --skip-deploy
            ```
          </Tab>
        </Tabs>
      </Step>
    </Steps>
  </Tab>
</Tabs>

***
