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

> ## Agent Instructions
> This page is part of the Solana developer documentation at https://solana.com/developers/docs. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get the page as Markdown.
> Index of all pages: https://solana.com/llms.txt. Per-section indexes such as https://solana.com/developers/docs/payments/llms.txt are smaller; prefer them when working on one task.
> Coding agents: install the official Solana skill for current APIs and conventions with `npx skills add https://github.com/solana-foundation/solana-dev-skill` (also served at https://solana.com/SKILL.md).
> Code in the cookbook and task pages comes from tested example files. Prefer it over writing API calls from memory.

# A Complete Guide to Solana Development for Ethereum Developers

> Map Ethereum accounts, contracts, transactions, fees, and tooling to Solana, port a Solidity contract to Anchor, and compare consensus on both networks.

Solana programs hold no state, one transaction can call several programs, and
fee pressure stays local to the accounts a transaction writes. This guide maps
Ethereum's accounts, contracts, transactions, fees, and tooling to their Solana
equivalents, ports a Solidity contract step by step, and compares how the two
networks reach consensus.

## At a glance

Use this table as a lookup while you read. Each row links an Ethereum concept to
the section that explains its Solana counterpart.

| Concept | Ethereum | Solana |
| --- | --- | --- |
| [Consensus](#consensus) | Gasper: Casper-FFG plus LMD-GHOST | Alpenglow: Votor voting and finality |
| [Finality](#consensus) | About 13 minutes (two epochs) | About 150 milliseconds |
| [State](#accounts) | Storage inside each contract account | Data accounts owned by programs |
| [User account](#accounts) | Externally owned account (EOA) | Account owned by the System Program and controlled by a keypair |
| [Smart contract](#programs) | Contract account holding code and storage | Program: an executable account with no state of its own |
| [Account abstraction](#accounts) | ERC4337 and EIP-7702 | Fee payers, multiple signers, and PDAs in the base protocol |
| [Validator software](#clients-and-nodes) | An execution client plus a consensus client | One validator client |

## The mental model: programs and accounts

The account model is the largest change when you move from Ethereum. A Solidity
contract keeps its code and its storage at one address. A Solana program is
stateless: it stores nothing itself, and every instruction passes in the
accounts it reads and writes.

Solana uses this design to run transactions in parallel. Each transaction
declares its accounts up front, so the runtime can execute transactions that do
not write the same accounts at the same time on separate cores.

```mermaid
flowchart TD
    C["Counter contract<br/>One address holds everything."]
    C -->|holds| C0["Code<br/>increment()"]
    C -->|holds| C1["Storage<br/>count"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="2afeb6ff4fa7">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/2afeb6ff4fa7-light.svg" alt="On Ethereum, one contract address holds the code and the count." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/2afeb6ff4fa7.svg" alt="On Ethereum, one contract address holds the code and the count." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/2afeb6ff4fa7-sm-light.svg" alt="On Ethereum, one contract address holds the code and the count." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/2afeb6ff4fa7-sm.svg" alt="On Ethereum, one contract address holds the code and the count." />
</div>

<p className="sol-caption">On Ethereum, one contract address holds the code and the count.</p>

```mermaid
flowchart TD
    P["Counter program<br/>increment instruction, no state"]
    P -->|owns| P0["Counter account<br/>count: 3"]
    P -->|owns| P1["Counter account<br/>count: 12"]
    P -->|owns| P2["Counter account<br/>count: 40"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="4c02a197edd1">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/4c02a197edd1-light.svg" alt="On Solana, one counter program serves any number of counter accounts." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/4c02a197edd1.svg" alt="On Solana, one counter program serves any number of counter accounts." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/4c02a197edd1-sm-light.svg" alt="On Solana, one counter program serves any number of counter accounts." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/4c02a197edd1-sm.svg" alt="On Solana, one counter program serves any number of counter accounts." />
</div>

<p className="sol-caption">On Solana, one counter program serves any number of counter accounts.</p>

In code, the Solidity contract declares `count` as a state variable. The Anchor
program declares a `Counter` account type and lists that account in the
`Increment` context. The caller chooses which counter account to pass in.

```solidity Solidity
contract Counter {
    uint256 public count;

    function increment() public {
        count += 1;
    }
}
```

```rust title="Rust with Anchor"
#[program]
pub mod counter {
    use super::*;

    pub fn increment(ctx: Context<Increment>) -> Result<()> {
        let counter = &mut ctx.accounts.counter;
        counter.count = counter.count.checked_add(1).unwrap();
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Increment<'info> {
    #[account(mut)]
    pub counter: Account<'info, Counter>,
}

#[account]
pub struct Counter {
    pub count: u64,
}
```

### One program, many accounts

Stateless programs are reusable. On Ethereum, every new ERC20 token is a new
contract deployment. On Solana, a new token is a new **mint account** under the
Token Program that is already deployed. The mint account records the supply, the
decimals, and who may mint or freeze.

```mermaid
flowchart TD
    P["Token Program<br/>Deployed once"]
    P -->|owns| P0["Mint account<br/>Token A: supply, decimals, authorities"]
    P -->|owns| P1["Mint account<br/>Token B: supply, decimals, authorities"]
    P -->|owns| P2["Token accounts<br/>Each holder's balance"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="3a0cc634824c">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/3a0cc634824c-light.svg" alt="Creating a token sends one transaction to the Token Program. You write no Rust and deploy no contract." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/3a0cc634824c.svg" alt="Creating a token sends one transaction to the Token Program. You write no Rust and deploy no contract." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/3a0cc634824c-sm-light.svg" alt="Creating a token sends one transaction to the Token Program. You write no Rust and deploy no contract." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/3a0cc634824c-sm.svg" alt="Creating a token sends one transaction to the Token Program. You write no Rust and deploy no contract." />
</div>

<p className="sol-caption">Creating a token sends one transaction to the Token Program. You write no Rust and deploy no contract.</p>

```bash Terminal
spl-token create-token
```

## Accounts

Ethereum has two kinds of accounts, and a contract account holds its own
storage. On Solana, every piece of state is an account with the same five
fields. This section compares the two models field by field.

### Ethereum accounts

Both kinds of Ethereum account have an address and can hold ETH. They differ in
what controls them:

<Columns cols={2}>
<Card title="Externally owned account: Controlled by a private key">

- Signs and starts transactions.
- Holds a balance and a nonce.
- Has no code unless it delegates to a contract with EIP-7702.

</Card>
<Card title="Contract account: Controlled by its code">

- Runs when a transaction or another contract calls it.
- Holds code and storage.
- Has no private key, so it cannot start a transaction.

</Card>
</Columns>

| Field | Description |
| --- | --- |
| `nonce` | Number of transactions the account has sent. For a contract, the number of contracts it has created. |
| `balance` | ETH the account holds, in wei. |
| `codeHash` | Hash of the account's EVM code. An EOA without a delegation has the hash of empty code. |
| `storageRoot` | Root hash of the Merkle Patricia trie that holds the contract's storage. |

### Solana accounts

On Solana, wallets, programs, token balances, and application state are all
[accounts](/developers/docs/core/accounts). An account works like a file: it has
an address, holds bytes, and carries metadata that tells the runtime who may
change it. Every account has the same five fields:

| Field | Description |
| --- | --- |
| `lamports` | Balance in lamports, the smallest unit of SOL. The equivalent of `balance`. |
| `data` | Byte array the account stores. For a program, this is the executable code or a pointer to it. |
| `owner` | Program that owns the account. Only the owner can change `data` or deduct lamports. |
| `executable` | Whether the account is a program. |
| `rent_epoch` | Legacy field. Rent collection is disabled, so the field no longer changes. |

Three rules follow from these fields:

- **Programs own data.** A program stores state in accounts it owns, and the
  runtime rejects writes from any other program. A wallet is an account owned by
  the System Program.
- **Programs can control addresses.** A [Program Derived Address
  (PDA)](/developers/docs/core/pda) is derived from a program ID and a set of
  seeds, and it has no private key. Only the program that derived it can sign
  for it. PDAs take the place of Solidity mappings: derive one address per key
  and store the value in that account.
- **Storage needs a deposit.** Each account holds a minimum lamport balance in
  proportion to its data size, called [rent](/developers/docs/core/rent). Rent
  is a refundable deposit, not a recurring fee: you pay it when you create the
  account and get it back when you close the account.

### Field by field

Most Ethereum account fields have a Solana counterpart. Two do not map one to
one: the nonce and the storage root.

| Ethereum | Solana | Notes |
| --- | --- | --- |
| `balance` | `lamports` | Both hold the native token balance. |
| `nonce` | No equivalent | Solana transactions expire with a recent blockhash, not an account nonce. |
| `codeHash` | `executable` and `data` | A program account is marked executable and stores the code. |
| `storageRoot` | `data` in separate accounts | State lives in data accounts that the program owns. |
| No equivalent | `owner` | Every Solana account names the program that controls it. |

### Account abstraction

On Ethereum, only an EOA can start a transaction and pay for gas, so sponsored
fees, batching, and custom signing rules need extra machinery. ERC4337 added
that machinery through a separate EntryPoint contract, bundlers, and paymasters,
and it went live on Ethereum mainnet in March 2023. EIP-7702, part of the Pectra
upgrade in May 2025, lets an EOA delegate to contract code.

Solana's transaction format covers fee sponsorship and batching without a
separate standard. Custom signing rules still need a wallet program, which signs
through a PDA:

<Columns cols={3}>
<Card title="Any wallet can pay the fee" href="/developers/docs/core/fees/fee-sponsorship" arrow>

The fee payer is one of the transaction's signers and must be an account owned
by the System Program. It does not have to be the user, so sponsored
transactions need no paymaster contract.

</Card>
<Card title="Several instructions and signers" href="/developers/docs/core/transactions" arrow>

One transaction can carry several instructions and several signatures, so
batching and multi-party signing need no bundler.

</Card>
<Card title="Programs sign for PDAs" href="/developers/docs/core/pda" arrow>

A program signs for its PDAs with `invoke_signed`, which lets it hold tokens and
enforce custom authorization rules.

</Card>
</Columns>

<Note>

**One limit remains**

A program cannot start a transaction. An external signer submits and pays for
every transaction: a user, a relayer, or a backend service.

</Note>

## Programs

A [program](/developers/docs/core/programs) is the account that holds executable
code. Each instruction names the accounts it reads and writes, and the runtime
passes those accounts to the program:

<Steps>
<Step title="Instruction arrives">

It names a program ID, a list of accounts, and a byte array of instruction data.

</Step>
<Step title="Runtime loads accounts">

The runtime checks signatures and loads every account the instruction lists.

</Step>
<Step title="Program executes">

One entrypoint receives the program ID, the accounts, and the instruction data.

</Step>
<Step title="Changes are committed">

The runtime keeps the account changes only if the owner rules hold and every
instruction succeeds.

</Step>
</Steps>

- A program is an account with `executable` set to true. A loader program owns
  it.
- Programs compile to sBPF, Solana's bytecode format. Most are written in Rust,
  and any language with an LLVM backend that targets sBPF works.
- Because state lives in accounts, one deployed program serves any number of
  users and assets without being deployed again.

### Native programs and the Solana Program Library

Solana ships with programs that most applications call instead of rewriting.
Native programs provide core functions: the System Program creates accounts and
transfers SOL. The Solana Program Library (SPL) covers tokens and related
functions: the Token Program mints and transfers tokens, and the Associated
Token Account Program creates each wallet's token account at a derived address.

### Writing programs

Most teams write programs in Rust with [Anchor](https://www.anchor-lang.com/), a
framework that generates account validation and serialization code.

A Rust program written without a framework usually splits into these files:

| File | Purpose |
| --- | --- |
| `lib.rs` | Registers the modules |
| `entrypoint.rs` | Entrypoint to the program |
| `instruction.rs` | Program API and instruction data (de)serialization |
| `processor.rs` | Program logic |
| `state.rs` | Account types and state (de)serialization |
| `error.rs` | Program-specific errors |

### Deploying and upgrading

Develop and test against a local validator or Devnet, then deploy to Mainnet.
Clients reach each cluster through its RPC endpoint. The public endpoints are
shared and rate-limited, so use an RPC provider in production:

| Cluster | RPC endpoint |
| --- | --- |
| Mainnet | `https://api.mainnet.solana.com` |
| Testnet | `https://api.testnet.solana.com` |
| Devnet | `https://api.devnet.solana.com` |
| Localhost | `http://localhost:8899` |

```bash Terminal
solana program deploy <PROGRAM_FILEPATH>
```

Deploying uploads the compiled program and creates a program account. That
account's address is the program ID that every instruction references.

Programs are upgradeable by default. The program's upgrade authority can replace
the code while the program ID stays the same, so you need no proxy contract. To
make a program immutable, remove the upgrade authority:

```bash Terminal
solana program set-upgrade-authority <PROGRAM_ADDRESS> --final
```

## Transactions and instructions

An [instruction](/developers/docs/core/instructions) is one call to one program,
the equivalent of a function call on an Ethereum contract. A
[transaction](/developers/docs/core/transactions) bundles one or more
instructions with the signatures that authorize them.

```mermaid
flowchart LR
    SIG["Signatures<br/>One per required signer. The first signer pays the fee."]
    MSG["Message<br/>Everything the signers sign."]
    MSG --> M0["Account addresses<br/>Every account the instructions read or write."]
    MSG --> M1["Recent blockhash<br/>Expires the transaction after 150 blocks, about 30 seconds."]
    MSG --> I0["Instruction 1: transfer tokens<br/>Program: Token Program<br/>Accounts: Source, destination, owner<br/>Data: Amount"]
    MSG --> I1["Instruction 2: call your program<br/>Program: Your program ID<br/>Accounts: Accounts your program needs<br/>Data: Arguments"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="9e5d95b775fd">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/9e5d95b775fd-light.svg" alt="A transaction runs its instructions in order. If one fails, the whole transaction fails." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/9e5d95b775fd.svg" alt="A transaction runs its instructions in order. If one fails, the whole transaction fails." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/9e5d95b775fd-sm-light.svg" alt="A transaction runs its instructions in order. If one fails, the whole transaction fails." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/9e5d95b775fd-sm.svg" alt="A transaction runs its instructions in order. If one fails, the whole transaction fails." />
</div>

<p className="sol-caption">A transaction runs its instructions in order. If one fails, the whole transaction fails.</p>

<Columns cols={2}>
<Card title="Ethereum transaction">

- Calls one contract. Batching needs a multicall contract.
- Has one sender. Each contract sees its immediate caller as `msg.sender`.
- Is ordered by the sender's account nonce.
- Does not have to declare state access up front.

</Card>
<Card title="Solana transaction">

- Carries several instructions, each to any program, and executes them
  atomically.
- Can have several signers, and the fee payer does not have to be the user.
- Uses a recent blockhash and expires after 150 blocks, about 30 seconds.
- Lists every account it reads or writes before execution.

</Card>
</Columns>

### From wallet to finality

Solana has no public mempool. An RPC node forwards a transaction straight to the
current leader and the next leaders on the schedule. If the transaction is not
included before its blockhash expires, the client signs a new one with a fresh
blockhash.

<Steps>
<Step title="Build and sign">

Your app builds the transaction and the wallet signs it.

</Step>
<Step title="Send over RPC">

The RPC node forwards it to the current and upcoming leaders.

</Step>
<Step title="Execute">

The leader runs the instructions and adds the transaction to a block.

</Step>
<Step title="Finalize">

Validators vote, and the block is final about 150 milliseconds after it is
produced.

</Step>
</Steps>

<Note>

**Choose a commitment level**

RPC reads and confirmations accept a
[`commitment`](/developers/docs/core/transactions/confirmation) level, which
replaces counting block confirmations on Ethereum. `processed` is the node's
newest block and can still be skipped. `finalized` is a block with a
finalization certificate. `confirmed` returns the same block as `finalized` and
is kept for compatibility. Use `finalized` before you ship goods, release funds,
or write settlement records.

</Note>

### Calling other programs

A [Cross-Program Invocation (CPI)](/developers/docs/core/cpi) is one program
calling an instruction on another, the way a Solidity contract calls another
contract. Three rules differ from the EVM:

- The transaction must list every account the whole call chain touches before
  execution starts.
- The callee receives only the signer and writable privileges the caller holds,
  and it spends from the same compute budget.
- Use `invoke` when the original signers cover the call. Use `invoke_signed`
  when your program signs for one of its PDAs.

## Fees and local fee markets

A Solana transaction pays up to three kinds of cost. Amounts are in lamports: 1
SOL is 1,000,000,000 lamports. Compute units play the role of gas.

<Columns cols={3}>
<Card title="Base fee">

**5,000 lamports.** Charged per signature. Half is burned and half goes to the
validator.

</Card>
<Card title="Priority fee">

**Optional.** Compute unit limit multiplied by the compute unit price you set,
in micro-lamports per compute unit. All of it goes to the validator that
produces the block.

</Card>
<Card title="Rent">

**Refundable deposit.** Sized by the bytes an account stores. You get it back
when you close the account.

</Card>
</Columns>

### Local fee markets

Because each transaction declares the accounts it writes, Solana prices
contention per account. A popular NFT mint raises priority fees for transactions
that write the mint's accounts. A USDC transfer that touches other accounts in
the same block keeps paying the usual fee. On Ethereum, one busy contract can
raise the base fee for every transaction in the block.

See [fees](/developers/docs/core/fees) for how to set a compute unit limit and
price.

## Limits to design around

Solana caps what one transaction and one block can do. Check a migrated design
against these numbers before you write code. The block limits are feature-gated,
so confirm the current values in the [compute
budget](/developers/docs/core/fees/compute-budget) reference.

<Columns cols={3}>
<Card title="Transaction size">

**1,232 bytes.** 4,096 bytes with the v1 transaction format.

</Card>
<Card title="Compute per transaction">

**1.4M compute units.** The default is 200,000 per instruction until you request
more.

</Card>
<Card title="Compute per block">

**50M compute units.** Shared by every transaction in the block. This limit
scales with slot time.

</Card>
<Card title="Compute per account">

**20M compute units.** Per block, for transactions that write the same account.
This limit scales with slot time.

</Card>
<Card title="Instruction stack depth">

**5.** The top-level instruction plus four nested CPIs. SIMD-0268 raises the
limit to 9 once it activates.

</Card>
<Card title="Blockhash lifetime">

**150 blocks.** About 30 seconds. After that, the transaction can no longer be
included.

</Card>
</Columns>

### Reentrancy

The runtime blocks the common `A -> B -> A` reentrancy path with a
`ReentrancyNotAllowed` error, so you do not need a `nonReentrant` guard for it.
A program can still call itself directly, within the stack depth and compute
limits. The risk moves elsewhere: callers choose the accounts and instruction
data they pass to your program, so validate every account and every CPI target.
See the full list of [program
limitations](/developers/docs/programs/limitations).

## Languages and tooling

Most EVM tools have a direct Solana counterpart.

| EVM tool | Solana equivalent | Use it for |
| --- | --- | --- |
| Hardhat node, Anvil | [Solana Test Validator](https://docs.anza.xyz/cli/examples/test-validator), [Surfpool](https://github.com/txtx/surfpool) | A local network. Surfpool can fork mainnet state. |
| Foundry tests | [LiteSVM](https://github.com/LiteSVM/litesvm), [Mollusk](https://github.com/anza-xyz/mollusk) | Fast in-process program tests. |
| Ethers, viem | [@solana/kit](https://github.com/anza-xyz/kit) | Building, signing, and sending transactions from JavaScript. |
| Remix | [Solana Playground](https://playground.solana.com) | Writing and deploying programs in the browser. |
| ABI | Anchor IDL | A JSON description of a program's instructions and accounts, used to generate clients. |
| Etherscan | [Solana Explorer](https://explorer.solana.com/), [Solscan](https://solscan.io/), [Orb](https://orbmarkets.io/) | Inspecting transactions, accounts, and programs. |
| scaffold-eth | [create-solana-dapp](https://github.com/solana-foundation/create-solana-dapp) | Scaffolding a full-stack app. |

### Programming languages

Most Solana programs are written in Rust, usually with the [Anchor
framework](https://www.anchor-lang.com/), which handles account validation and
serialization.

On the client side, SDKs exist for most languages:

| Language | SDK |
| --- | --- |
| JavaScript and TypeScript | [@solana/kit](https://github.com/anza-xyz/kit) (legacy: [@solana/web3.js](https://github.com/solana-foundation/solana-web3.js)) |
| Rust | [solana_sdk](https://docs.rs/solana-sdk/latest/solana_sdk/) |
| Python | [solana-py](https://github.com/michaelhly/solana-py) |
| Go | [solana-go](https://github.com/solana-foundation/solana-go) |
| Java | [solanaj](https://github.com/skynetcap/solanaj) |
| C# | [Solnet](https://github.com/bmresearch/Solnet) |
| C++ | [solcpp](https://github.com/mschneider/solcpp) |

### Reading program source

On Ethereum, you read a contract's source on Etherscan after the deployer
verifies it. Solana's counterpart is [verified
builds](/developers/docs/programs/verified-builds). The author builds the
program deterministically and records the repository and commit onchain.
[OtterSec's verification
service](https://github.com/otter-sec/solana-verified-programs-api) reproduces
the build from that repository, and explorers show the result on the program's
page. A program without a verified build shows only bytecode. Treat it like an
unverified contract.

## Solidity patterns on Solana

Most Solidity idioms have a Solana equivalent, though few translate line by
line. Use this map when you read a contract you plan to port.

| Solidity | Solana | How it maps |
| --- | --- | --- |
| `mapping` | Program Derived Addresses | Derive one account address per key from seeds, and store the value in that account. |
| `msg.sender` | `Signer` accounts | A transaction can have several signers, and the fee payer may be someone else. List each required signer as an account and check it. |
| `constructor` | An initialize instruction | Create and fill the program's accounts in a dedicated instruction, and block it from running twice. |
| `onlyOwner` | Signer and address checks | Store the authority's address in an account or a constant, and require that address to sign. |
| `view` functions | Client-side account reads | Account data is public. Fetch and decode it over RPC without calling the program. |
| Proxy upgrades | Upgrade authority | Programs are upgradeable by default. Redeploy to the same program ID, or remove the authority to make the program immutable. |
| `nonReentrant` | Account and CPI validation | The runtime blocks indirect reentrancy. Verify account owners, PDA seeds, and the program IDs you call. |
| An ERC20 contract | A mint account | Create a mint under the Token Program instead of deploying token code. |

### Mappings become PDAs

A [Program Derived Address (PDA)](/developers/docs/core/pda) gives you the
key-to-value lookup that `mapping` provides. The seeds are the key, and the
account at the derived address holds the value. In this example, the string
`balance` and the signer's public key derive one balance account per user:

```solidity Solidity
mapping(address => uint256) public balances;
```

```rust title="Rust with Anchor"
#[account(
    init,
    payer = signer,
    space = 8 + Balance::INIT_SPACE,
    seeds = [b"balance", signer.key().as_ref()],
    bump
)]
pub balance: Account<'info, Balance>,
```

## Port a Solidity contract

This walkthrough ports a small voting contract. The Solidity version stores a
vote count per candidate in a mapping, sets the candidate list in its
constructor, and exposes one function to vote:

```solidity
contract Voting {
    mapping(bytes32 => uint256) public votesReceived;
    bytes32[] public candidateList;

    constructor(bytes32[] memory candidateNames) {
        candidateList = candidateNames;
    }

    function voteForCandidate(bytes32 candidate) public {
        require(validCandidate(candidate));
        votesReceived[candidate] += 1;
    }

    function validCandidate(bytes32 candidate) public view returns (bool) {
        for (uint256 i = 0; i < candidateList.length; i++) {
            if (candidateList[i] == candidate) return true;
        }
        return false;
    }
}
```

<Steps>
<Step title="Map functions to instructions">

The constructor becomes `init_candidate`, and `voteForCandidate` becomes
`vote_for_candidate`. Each instruction takes a context that lists its accounts.

```rust
#[program]
pub mod voting {
    use super::*;

    #[access_control(check(&ctx))]
    pub fn init_candidate(
        ctx: Context<InitializeCandidate>,
        _candidate_name: String,
    ) -> Result<()> {
        Ok(())
    }

    pub fn vote_for_candidate(
        ctx: Context<VoteCandidate>,
        _candidate_name: String,
    ) -> Result<()> {
        let candidate = &mut ctx.accounts.candidate;
        candidate.votes_received = candidate.votes_received.checked_add(1).unwrap();
        Ok(())
    }
}
```

</Step>
<Step title="Define the account that stores votes">

Replace the `votesReceived` mapping with a `Candidate` account type. `InitSpace`
calculates how many bytes the account needs.

```rust
#[account]
#[derive(InitSpace)]
pub struct Candidate {
    pub votes_received: u64,
}
```

</Step>
<Step title="Derive one account per candidate">

Use the candidate name as the PDA seed. `init` creates the account, `payer`
funds its rent deposit, and `space` adds 8 bytes for the discriminator, the tag
Anchor writes at the start of each account to identify its type. A seed holds at
most 32 bytes, so hash longer names. The `VoteCandidate` context, not shown,
uses the same seeds with `mut` in place of `init`.

```rust
#[derive(Accounts)]
#[instruction(_candidate_name: String)]
pub struct InitializeCandidate<'info> {
    #[account(mut)]
    pub payer: Signer<'info>,

    #[account(
        init,
        space = 8 + Candidate::INIT_SPACE,
        payer = payer,
        seeds = [_candidate_name.as_bytes().as_ref()],
        bump,
    )]
    pub candidate: Account<'info, Candidate>,
    pub system_program: Program<'info, System>,
}
```

</Step>
<Step title="Restrict who can add candidates">

A Solidity constructor runs once, for the deployer. Anyone can call a Solana
instruction, so `init_candidate` checks that the signer is the owner. This check
stands in for both the constructor and `onlyOwner`. `OnlyOwnerError` is a custom
error enum, not shown.

```rust
const OWNER: &str = "8os8PKYmeVjU1mmwHZZNTEv5hpBXi5VvEKGzykduZAik";

fn check(ctx: &Context<InitializeCandidate>) -> Result<()> {
    require_keys_eq!(
        ctx.accounts.payer.key(),
        OWNER.parse::<Pubkey>().unwrap(),
        OnlyOwnerError::NotOwner
    );
    Ok(())
}
```

</Step>
<Step title="Deploy and vote">

Create a project with `anchor init`, add the program code, and set the `OWNER`
constant to the address of the wallet that runs your tests. Run `anchor build`,
then `anchor test` to deploy to a local validator and call `init_candidate` and
`vote_for_candidate` from a test. [Build your first
program](/developers/docs/programs/build-first-program) walks through this
workflow.

</Step>
<Step title="Read the results">

Fetch the `Candidate` accounts from the client. In an Anchor test,
`program.account.candidate.all()` returns each candidate with its vote count.

</Step>
</Steps>

<Note>

**What happened to the view functions?**

`validCandidate` is no longer needed: `vote_for_candidate` fails when the
candidate account does not exist. The `votesReceived` getter moves to the
client, which reads the `Candidate` account directly.

</Note>

## Security checklist

Reentrancy is a standard item in an EVM security review. On Solana, the main
items are account and CPI validation, because callers control the accounts and
instruction data they pass in. Check each item before you deploy a migrated
program.

- Validate every account's owner, address or PDA seeds, discriminator, and data
  length, and how it relates to the other accounts in the instruction.
- Require each authority as an explicit signer or a validated PDA. There is no
  implicit `msg.sender`.
- Reject duplicate mutable accounts when the instruction expects separate
  balances, vaults, or config accounts.
- Pin CPI targets to the expected program IDs so a caller cannot substitute a
  program or an account.
- Protect initialization from running twice, especially with helpers such as
  `init_if_needed`.
- Close accounts by draining their lamports and marking the state closed, so
  they cannot be revived in the same transaction.
- Use checked math, and confirm that token decimals, mint addresses, and the
  token program match your Solidity assumptions.
- Test account substitution, signer spoofing, arbitrary CPI program IDs,
  duplicate writable accounts, reinitialization, account closure, and stale
  reads after a CPI.

## Consensus and finality

Ethereum and Solana both use Proof of Stake (PoS): validators stake tokens to
earn the right to produce blocks and vote on them. The two chains differ in how
validators reach agreement and in how long a block takes to become final.

<Columns cols={2}>
<Card title="Ethereum finality">

**~13 minutes.** Two epochs of attestations under Gasper.

</Card>
<Card title="Solana finality">

**~150 milliseconds.** One or two rounds of Votor votes under Alpenglow.

</Card>
</Columns>

### Ethereum: Gasper

Ethereum launched on Proof of Work and moved to Proof of Stake with the Merge in
September 2022. Its consensus algorithm, Gasper, combines two parts:

- **LMD-GHOST** is the fork choice rule. When several blocks compete, validators
  publish attestations, and the chain follows the branch with the most stake
  behind it, counting each validator's latest attestation.
- **Casper-FFG** is the finality gadget. It marks checkpoint blocks as justified
  and then finalized once two-thirds of stake has attested across two epochs.

### Solana: Alpenglow

Alpenglow is Solana's consensus protocol. Its voting component, **Votor**,
finalizes a block in one or two rounds of votes:

<Steps>
<Step title="Leader produces a block">

The validator scheduled for the slot builds a block and broadcasts it with
Turbine.

</Step>
<Step title="Validators vote">

Validators send votes directly to one another. Votes are not transactions inside
blocks.

</Step>
<Step title="Votes form a certificate">

Votes aggregate into a stake-weighted certificate: 80% of stake in one round, or
60% of stake in each of two rounds.

</Step>
<Step title="Block is final">

A block with a finalization certificate is final. Reversing it would take more
than 20% of stake acting against the protocol.

</Step>
</Steps>

Alpenglow replaced Tower BFT on Mainnet in October 2026. Tower BFT was a variant
of Practical Byzantine Fault Tolerance (PBFT) that used Proof of History (PoH)
as a shared clock and recorded votes as onchain transactions. Votor replaced
that voting layer, and Proof of History is no longer part of how validators
reach agreement.

Alpenglow has a second component, **Rotor**, which is planned and not live yet.
Solana still propagates blocks with Turbine, its tree-based broadcast protocol.
Rotor will replace it with a single relay layer that cuts the network hops
between the leader and the other validators.

<Note>

**What changes for your app**

Signing, sending, and reading transactions work the same way, and finality
arrives sooner. See [commitment levels](#transactions) for which level to wait
for.

</Note>

| Role | Ethereum | Solana |
| --- | --- | --- |
| Sybil resistance | Proof of Stake (Proof of Work before 2022) | Proof of Stake |
| Finality | Casper-FFG checkpoints | Votor certificates |
| Voting and fork choice | LMD-GHOST attestations | Votor votes (Tower BFT with PoH before Alpenglow) |
| Block propagation | Gossip | Turbine (Rotor planned) |

## Clients and nodes

Both networks have more than one validator client, which limits the damage a bug
in one implementation can do. They differ in how the software is split.

<Columns cols={2}>
<Card title="Ethereum: Two clients per validator">

- An execution client receives transactions, runs them in the EVM, and keeps the
  state.
- A consensus client runs Proof of Stake and agrees on the blocks the execution
  client validated.

</Card>
<Card title="Solana: One client per validator">

- A single validator client executes transactions, produces blocks, and votes.

</Card>
</Columns>

### Validator clients

The share of Ethereum validators running each client is tracked at
[clientdiversity.org](https://clientdiversity.org/#distribution).

| Network and role | Clients |
| --- | --- |
| Ethereum execution | Geth (Go), Nethermind (C#), Besu (Java), Erigon (Go), Reth (Rust) |
| Ethereum consensus | Lighthouse (Rust), Prysm (Go), Teku (Java), Nimbus (Nim), Lodestar (TypeScript) |
| Solana validator | Agave (Rust), Jito-Solana (Rust, a fork of Agave), Firedancer (C), Sig (Zig) |

### Node types

Ethereum classifies nodes by how much history they store: full, archive, and
light. Solana classifies them by whether they vote. Its transaction volume makes
it impractical for every node to keep the full ledger, so history is served from
external archives.

| Role | Ethereum | Solana |
| --- | --- | --- |
| Votes in consensus | Validator running a full node | Voting validator |
| Serves app reads and submits transactions | Full or archive node behind an RPC endpoint | RPC node: verifies every block and does not vote |
| Keeps full history | Archive node | External archives such as Bigtable-backed warehouses or Old Faithful |
| Verifies block headers only | Light node | No widely deployed equivalent |

Applications on both chains usually read and write through an RPC provider. Some
providers serve both Ethereum and Solana. See the [list of Solana RPC
providers](https://solana.com/rpc).

## Next steps

<Columns cols={3}>
<Card title="ERC Standards" href="/developers/docs/migrate-to-solana/ethereum/standards">

Find the Solana equivalent of the standard you are porting.

</Card>
<Card title="ERC20 on Solana" href="/developers/docs/migrate-to-solana/ethereum/standards/erc20">

Create and transfer tokens with the Token Program.

</Card>
<Card title="Quickstart" href="/developers/docs/quickstart" arrow>

Send your first transactions on Solana.

</Card>
</Columns>
