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

# Setup

> Set up your development environment for building Confidential SPL Tokens

# Environment Setup

This guide walks you through setting up your development environment for deploying and testing Confidential SPL tokens on Solana devnet.

## Prerequisites

Before you begin, make sure you have the following installed:

| Tool       | Version       | Installation                                                                        |
| ---------- | ------------- | ----------------------------------------------------------------------------------- |
| Rust       | Latest stable | `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \| sh`                   |
| Solana CLI | 1.18+         | `sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"`                     |
| Anchor     | 0.31.1        | `cargo install --git https://github.com/coral-xyz/anchor avm && avm install 0.31.1` |
| Node.js    | 18+           | `nvm install 18`                                                                    |
| Yarn       | Latest        | `npm install -g yarn`                                                               |

## Configure Solana for Devnet

```bash theme={null}
# Set Solana to use devnet
solana config set --url devnet

# Verify configuration
solana config get

# Create a new wallet (if you don't have one)
solana-keygen new --outfile ~/.config/solana/id.json

# Get some devnet SOL for testing
solana airdrop 2

# Check your balance
solana balance
```

## Environment Variables

Create a `.env` file in your project root:

```bash theme={null}
# Co-validator public key for encryption
SERVER_PUBLIC_KEY=0486ca2bbf34bea44c6043f23ebc5b67ca7ccefc3710498385ecc161460a1f8729db2a361cb0d7f40847a99a75572bc10e36a365218f4bae450dc61348330bb717

# Co-validator endpoint for decryption requests
COVALIDATOR_ENDPOINT=https://grpc.solana-devnet.alpha.devnet.inco.org

# Your Solana cluster
RPC_URL=https://api.devnet.solana.com

# Path to your wallet keypair
SOLANA_WALLET=~/.config/solana/id.json
```

## Project Setup

```bash theme={null}
# Clone the repository
git clone https://github.com/Inco-fhevm/lightning-rod-solana.git
cd lightning-rod-solana

# Install dependencies
yarn install

# Build the programs
anchor build
```

## Anchor.toml Configuration

```toml theme={null}
[features]
resolution = true
skip-lint = false

[programs.devnet]
inco_token = "<your_program_id>"

[registry]
url = "https://api.apr.dev"

[provider]
cluster = "devnet"
wallet = "~/.config/solana/id.json"

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
```

<Note>
  You only need to add your own program ID here. The Inco Lightning program ID is handled internally by the `inco-lightning` crate via the `INCO_LIGHTNING_ID` constant.
</Note>

## Cargo.toml (Workspace)

```toml theme={null}
[workspace]
members = [
    "programs/*"
]
resolver = "2"

[profile.release]
overflow-checks = true
lto = "fat"
codegen-units = 1

[profile.release.build-override]
opt-level = 3
incremental = false
codegen-units = 1
```

## Cargo.toml (Program)

Located at `programs/inco-token/Cargo.toml`:

```toml theme={null}
[package]
name = "inco-token"
version = "0.1.0"
description = "Encrypted Token Program for Solana using Inco Lightning"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "inco_token"

[features]
default = []
cpi = ["no-entrypoint"]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"]

[dependencies]
anchor-lang = { version = "0.31.1", features = ["init-if-needed"] }
anchor-spl = "0.31.1"
inco-lightning = { version = "0.1.4", features = ["cpi"] }
```

## package.json

```json theme={null}
{
  "name": "lightning-rod-solana",
  "version": "0.1.0",
  "description": "Encrypted Token Program for Solana using Inco Lightning",
  "type": "module",
  "dependencies": {
    "@coral-xyz/anchor": "^0.31.0",
    "@inco/solana-sdk": "latest",
    "@noble/ed25519": "^2.3.0",
    "@solana/web3.js": "^1.98.0"
  },
  "devDependencies": {
    "@types/bn.js": "^5.1.6",
    "@types/chai": "^5.2.1",
    "@types/mocha": "^10.0.10",
    "chai": "^5.2.0",
    "dotenv": "^16.4.7",
    "mocha": "^11.1.0",
    "ts-mocha": "^11.1.0",
    "typescript": "^5.8.3"
  },
  "scripts": {
    "build": "anchor build",
    "test": "anchor test",
    "test:token": "ts-mocha -p ./tsconfig.json -t 1000000 tests/inco-token.ts"
  }
}
```

## Build and Deploy

```bash theme={null}
# Build all programs
anchor build

# Get your program ID
solana address -k target/deploy/inco_token-keypair.json

# Update the program ID in Anchor.toml and lib.rs declare_id!()
# Then rebuild
anchor build

# Deploy to devnet
anchor deploy --provider.cluster devnet

# Verify deployment
solana program show <your-program-id>
```

<Note>
  After deploying, make sure to update the `declare_id!` macro in your `lib.rs` with the actual deployed program ID.
</Note>

## Next Steps

Once your environment is set up, you can start using the [Program Functions](/svm/tutorials/confidential-spl-token/program-functions) to create and manage confidential tokens.
