> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/solana-foundation/anchor/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Anchor is the leading development framework for building secure Solana programs (smart contracts)

Anchor is the leading development framework for building Solana programs (smart contracts) and simplifies the process of writing, testing, deploying, and interacting with Solana programs.

The Anchor framework helps developers build production-ready applications faster while reducing potential vulnerabilities through built-in security features.

## Why Anchor?

Anchor transforms Solana program development by providing powerful abstractions and safety guarantees that eliminate common security pitfalls and reduce boilerplate code.

<CardGroup cols={2}>
  <Card title="Built-in security" icon={<Shield className="text-green-400" />}>
    Automatic account validation and security checks protect against common vulnerabilities
  </Card>

  <Card title="Less boilerplate" icon={<Code2 className="text-blue-400" />}>
    Rust macros eliminate repetitive code for account validation, serialization, and deserialization
  </Card>

  <Card title="Fast development" icon={<Zap className="text-yellow-400" />}>
    Built-in CLI tools for project scaffolding, building, testing, and deploying programs
  </Card>

  <Card title="TypeScript client" icon={<TestTube className="text-purple-400" />}>
    Auto-generated TypeScript clients from your program's IDL for seamless frontend integration
  </Card>
</CardGroup>

## Key features

### Simplified program structure

Anchor uses Rust macros to reduce boilerplate and enforce best practices:

```rust theme={null}
use anchor_lang::prelude::*;

declare_id!("YourProgramIDHere");

#[program]
pub mod my_program {
    use super::*;
    
    pub fn initialize(ctx: Context<Initialize>, data: u64) -> Result<()> {
        let account = &mut ctx.accounts.account;
        account.data = data;
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Initialize<'info> {
    #[account(init, payer = user, space = 8 + 8)]
    pub account: Account<'info, MyAccount>,
    #[account(mut)]
    pub user: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
pub struct MyAccount {
    pub data: u64,
}
```

### Automatic account validation

Anchor's account constraints provide compile-time and runtime validation:

* **Type safety**: Account types ensure the correct program owns each account
* **Constraint validation**: Built-in checks like `init`, `mut`, `has_one`, and `constraint`
* **Discriminators**: Automatic 8-byte discriminators prevent account type confusion

### IDL generation

Anchor automatically generates an Interface Description Language (IDL) file that describes your program's public interface. This JSON file enables:

* Auto-generated TypeScript clients
* Easy program integration
* Clear API documentation

### Testing framework

Built-in testing support with TypeScript:

```typescript theme={null}
import * as anchor from "@anchor-lang/core";
import { Program } from "@anchor-lang/core";
import { MyProgram } from "../target/types/my_program";

describe("my-program", () => {
  const provider = anchor.AnchorProvider.env();
  anchor.setProvider(provider);

  const program = anchor.workspace.MyProgram as Program<MyProgram>;

  it("Initializes an account", async () => {
    const tx = await program.methods.initialize(new anchor.BN(42)).rpc();
    console.log("Transaction signature:", tx);
  });
});
```

## Get started

<CardGroup cols={2}>
  <Card title="Installation" icon={<Download className="text-purple-400" />} href="/installation">
    Install Rust, Solana CLI, and Anchor CLI to set up your development environment
  </Card>

  <Card title="Quickstart" icon={<BookOpen className="text-blue-400" />} href="/quickstart">
    Build and deploy your first Anchor program in minutes
  </Card>
</CardGroup>

## What you'll build

In the quickstart guide, you'll create a simple counter program that demonstrates:

* Creating and initializing program accounts
* Incrementing a counter value
* Account validation with constraints
* Testing with TypeScript

This foundational example will prepare you to build more complex Solana programs with Anchor.
