# Create programs on X1

You can also use [playground](https://beta.solpg.io/).

This section covers the steps to set up your local environment for X1 development.

## Quick installation

On Linux, run this single command to install all dependencies.

```sh
curl --proto '=https' --tlsv1.2 -sSfL https://raw.githubusercontent.com/solana-developers/solana-install/main/install.sh | bash
```

After installation, you should see output similar to the following:

```
Installed Versions:
Rust: rustc 1.84.1 (e71f9a9a9 2025-01-27)
Solana CLI: solana-cli 2.0.26 (src:3dccb3e7; feat:607245837, client:Agave)
Anchor CLI: anchor-cli 0.30.1
Node.js: v23.7.0
Yarn: 1.22.1
```

If the quick installation command above doesn't work, please refer to instructions below to install each dependency individually.

## Install needed libraries

{% code overflow="wrap" %}

```sh
sudo apt-get update && sudo apt-get upgrade && sudo apt-get install -y pkg-config build-essential libudev-dev libssl-dev npm
```

{% endcode %}

```sh
sudo npm install -g yarn
```

## Install the Solana CLI(Linux)

The Solana CLI provides all the tools required to build and deploy Solana programs.

Install the Solana CLI tool suite using the official install command:

```sh
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
```

You can replace `stable` with the release tag matching the software version of your desired release (i.e. `v2.0.3`), or use one of the three symbolic channel names: `stable`, `beta`, or `edge`.

If it is your first time installing the Solana CLI, you may see the following message prompting you to add a `PATH` environment variable:

```
Close and reopen your terminal to apply the PATH changes or run the following in your existing shell:
export PATH="/Users/test/.local/share/solana/install/active_release/bin:$PATH"
```

If you are using a Linux or WSL terminal, you can add the `PATH` environment variable to your shell configuration file by running the command logged from the installation or by restarting your terminal.

```sh
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
```

To verify that the installation was successful, check the Solana CLI version:

```sh
solana-cli 2.0.26 (src:3dccb3e7; feat:607245837, client:Agave)
```

To later update the Solana CLI to the latest version, you can use the following command:

```sh
agave-install update
```

## Create keypair

Using command **solana-keygen** to generate a new wallet. It will generate a 12-word seed (aka. mnemonic, or recovery) phrase. Save it safe.

```sh
solana-keygen new --no-passphrase -o ~/.config/solana/id.json
```

```
solana config set -k ~/.config/solana/id.json
```

## Install rust and cargo

```
curl https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
```

Use the latest stable rust version:

```
rustup update
```

Check version:

```
cargo -V
```

On Linux systems you may need to install libssl-dev, pkg-config, zlib1g-dev, protobuf etc.

{% code overflow="wrap" %}

```
sudo apt-get update
sudo apt-get install libssl-dev libudev-dev pkg-config zlib1g-dev llvm clang cmake make libprotobuf-dev protobuf-compiler
```

{% endcode %}

Rust installation link for reference:

{% embed url="<https://www.rust-lang.org/tools/install>" %}

## Install anchor

Install **avm** using Cargo. Note this will replace your anchor binary if you had one installed:

```
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
```

Install the latest version of the CLI using avm, and then set it to be the version to use:

```
avm install latest
avm use latest
```

Verify installation:

```
anchor --version
```

Anchor installation link for reference:

{% embed url="<https://www.anchor-lang.com/docs/installation>" %}

## Create and deploy a program with Anchor

### Initialise a new project

```
anchor init <project name>
```

```
cd <project name>
```

### Display Anchor.toml

```
cat Anchor.toml
```

programs: \<project name> = "program ID"\
cluster = localnet\
wallet = path to wallet\
scripts: how yarn is used to run a test

### Change provider to X1 Testnet RPC

```
nano Anchor.toml
```

Change localnet to: <https://rpc.testnet.x1.xyz>

### Set to X1 testnet

```
solana config set -u https://rpc.testnet.x1.xyz
```

To verify set network, use:

```
solana config get
```

### Fund wallet

{% embed url="<https://faucet.testnet.x1.xyz/>" %}

Verify received airdrop:

```
solana balance
```

### Build project

```
anchor build
```

### Deploy program

```
anchor test
```

### Confirm test transaction

```
solana confirm -v <tx hash>
```

Or:

{% embed url="<https://explorer.x1.xyz/>" %}

### Modify program

```
cd programs/<project name>/src
```

```
nano lib.rs
```

Go back to original \<project name> directory, before building and deploying program again.

### If error

{% hint style="info" %}
**instruction 0: account data too small for instruction**
{% endhint %}

The byte size is pre-set for initial deployment. You can increase byte size by:

```
solana program extend <program id> 15000
```

## Tutorial

{% embed url="<https://www.youtube.com/watch?v=gnDzOPK8jMc&t>" %}


---

# Agent Instructions: 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:

```
GET https://docs.x1.xyz/build-on-x1/create-programs-on-x1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
