> ## 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.

# Account Structure

> Account addresses, the five fields every Solana account contains — lamports, data, owner, executable, and rent_epoch — with interactive code walkthrough.

<Info>
  **Summary**

  Accounts have 5 fields: lamports, data, owner, executable, and rent_epoch.
  Each account is identified by a unique 32-byte address. Accounts must hold a
  minimum lamport balance proportional to their data size to stay onchain.
</Info>

## Account address

Every account address is a 32-byte value, displayed as a base58-encoded string.
An address can be one of two types:

1. **Public key**: corresponds to an [Ed25519](https://ed25519.cr.yp.to/)
   keypair (has a private key)
2. **Program-derived address (PDA)**: deterministically derived from a program
   ID and seeds (no private key)

<Frame caption="Every account is found by its address, a 32-byte public key written in base58.">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/core/accounts/account-address-light.svg" alt="Every account is found by its address, a 32-byte public key written in base58." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/core/accounts/account-address.svg" alt="Every account is found by its address, a 32-byte public key written in base58." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/core/accounts/account-address-sm-light.svg" alt="Every account is found by its address, a 32-byte public key written in base58." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/core/accounts/account-address-sm.svg" alt="Every account is found by its address, a 32-byte public key written in base58." />
</Frame>

### Public key

A `Keypair` consists of a public key (used as the account address) and a
private key (used to sign transactions). The following example generates a
keypair using the Solana SDK.

<Note>
  The Rust tabs on this page use the 2.x Solana crates. Install the
  dependencies with (tested with Rust 1.89 and 1.98):

  ```bash
  cargo add solana-sdk@2
  cargo add tokio --features full
  ```
</Note>

<CodeGroup>

```ts Kit
import { generateKeyPairSigner } from "@solana/kit";

// Kit does not enable extractable private keys
const keypairSigner = await generateKeyPairSigner();
console.log(keypairSigner);
```

```ts title="Web3.js v3"
import { Keypair } from "@solana/web3.js";

const keypair = await Keypair.generate();
console.log(`Public Key: ${keypair.publicKey}`);
console.log(`Secret Key: ${keypair.secretKey}`);
```

```rs Rust
use solana_sdk::signer::{keypair::Keypair, Signer};

#[tokio::main]
async fn main() {
    let keypair = Keypair::new();
    println!("Public Key: {}", keypair.pubkey());
    println!("Secret Key: {:?}", keypair.to_bytes());
}
```

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts title="Web3.js (legacy)"
import { Keypair } from "@solana/web3.js";

const keypair = Keypair.generate();
console.log(`Public Key: ${keypair.publicKey}`);
console.log(`Secret Key: ${keypair.secretKey}`);
```

</CodeGroup>

### Program-derived address

A [program-derived address](/developers/docs/core/pda) (PDA) is deterministically derived
from a program ID and one or more optional seeds. PDAs do not have a
corresponding private key. The following example derives a PDA using the Solana
SDK.

<CodeGroup>

```ts Kit
import { Address, getProgramDerivedAddress } from "@solana/kit";

const programAddress = "11111111111111111111111111111111" as Address;

const seeds = ["helloWorld"];
const [pda, bump] = await getProgramDerivedAddress({
  programAddress,
  seeds
});

console.log(`PDA: ${pda}`);
console.log(`Bump: ${bump}`);
```

```ts title="Web3.js v3"
import { PublicKey } from "@solana/web3.js";

const programAddress = new PublicKey("11111111111111111111111111111111");

const seeds = [Buffer.from("helloWorld")];
const [pda, bump] = await PublicKey.findProgramAddress(seeds, programAddress);

console.log(`PDA: ${pda}`);
console.log(`Bump: ${bump}`);
```

```rs Rust
use solana_sdk::pubkey; // macro
use solana_sdk::pubkey::Pubkey;

#[tokio::main]
async fn main() {
    let program_address = pubkey!("11111111111111111111111111111111");
    let seeds = [b"helloWorld".as_ref()];
    let (pda, bump) = Pubkey::find_program_address(&seeds, &program_address);
    println!("PDA: {}", pda);
    println!("Bump: {}", bump);
}
```

<Warning>
  **`@solana/web3.js` 1.x is no longer actively maintained**

  It receives critical fixes only. Use [Kit](/developers/docs/clients/official/javascript#solana-kit) for new code. To migrate existing code, follow the [Kit upgrade guide](https://www.solanakit.com/docs/upgrade-guide), or the [web3.js v3 migration guide](https://github.com/solana-foundation/solana-web3.js/blob/main/docs/web3js-v1-to-v3-migration.md) to keep the class-based API.

  To run this code, install 1.x with `npm install @solana/web3.js@1`. A plain `npm install @solana/web3.js` installs v3, which this code doesn't run on.
</Warning>

```ts title="Web3.js (legacy)"
import { PublicKey } from "@solana/web3.js";

const programAddress = new PublicKey("11111111111111111111111111111111");

const seeds = [Buffer.from("helloWorld")];
const [pda, bump] = PublicKey.findProgramAddressSync(seeds, programAddress);

console.log(`PDA: ${pda}`);
console.log(`Bump: ${bump}`);
```

</CodeGroup>

## Account fields

Every
[`Account`](https://github.com/anza-xyz/solana-sdk/blob/clock%40v2.2.3/account/src/lib.rs#L32-L56)
has a maximum size of
[`MAX_ACCOUNT_DATA_LEN`](https://github.com/anza-xyz/agave/blob/v3.1.8/transaction-context/src/lib.rs#L34)
(10 MiB, equivalent to `MAX_PERMITTED_DATA_LENGTH`) and contains five
fields:

| Field        | Type      | Description                                                         |
| ------------ | --------- | ------------------------------------------------------------------- |
| `lamports`   | `u64`     | Balance in lamports. Owner can debit; any program can credit.       |
| `data`       | `Vec<u8>` | Account state or program bytecode. Max 10 MiB. Owner-writable only. |
| `owner`      | `Pubkey`  | Program with write access. Reassignable only when data is zeroed.   |
| `executable` | `bool`    | True = program account.                                             |
| `rent_epoch` | `Epoch`   | Deprecated. Set to `u64::MAX` for rent-exempt accounts.             |

```rust Account
pub struct Account {
    /// lamports in the account
    pub lamports: u64,
    /// data held in this account
    #[cfg_attr(feature = "serde", serde(with = "serde_bytes"))]
    pub data: Vec<u8>,
    /// the program that owns this account. If executable, the program that loads this account.
    pub owner: Pubkey,
    /// if true, this account's data contains a program (and is now read-only)
    pub executable: bool,
    /// deprecated
    pub rent_epoch: Epoch,
}
```

<Steps>
  <Step title="Lamports">
    The `lamports` field holds the account's balance in
    [lamports](/developers/docs/references/terminology#lamport) (1 SOL = 1,000,000,000
    lamports).

    Every account must maintain a minimum lamport balance to keep its data stored
    onchain. This refundable storage balance is proportional to the account's data
    size.

    <Info>
      The runtime and RPC method names call this the "rent-exempt minimum," but
      ongoing rent collection is disabled. Treat the balance as a refundable account
      storage deposit: the full balance can be recovered when the account is closed.
    </Info>

    See
    [`minimum_balance()`](https://github.com/anza-xyz/solana-sdk/blob/clock%40v2.2.3/rent/src/lib.rs#L93)
    and the rent
    [constants](https://github.com/anza-xyz/solana-sdk/blob/clock%40v2.2.3/rent/src/lib.rs#L47-L80).

    In the examples, the 82-byte mint holds exactly its minimum balance (1,066,800
    lamports on Mainnet in November 2026). The Token Program account, read from
    Mainnet, holds more than the 833,120-lamport minimum for its 36 bytes,
    because anyone can send lamports to an address.

    ```rust title="Account Examples" focus={3,13}
    // Example Token Mint Account
    Account {
        lamports: 1066800,
        data.len: 82,
        owner: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb,
        executable: false,
        rent_epoch: 18446744073709551615,
        data: 010000001e213c90625a7e643d9555bb01b6c3fe6416d7afd523ce8c7ddd9b923ceafb9d00000000000000000901010000001e213c90625a7e643d9555bb01b6,
    }

    // Example Token Program Account
    Account {
        lamports: 230130698,
        data.len: 36,
        owner: BPFLoaderUpgradeab1e11111111111111111111111,
        executable: true,
        rent_epoch: 18446744073709551615,
        data: 0200000027f190b1d3af98b8ce714c44e8cadff9f8fc45cb8e5fac4202eff8110d97dd37,
    }
    ```
  </Step>

  <Step title="Data">
    The `data` field stores an arbitrary byte array. Its contents depend on the
    account type:

    - **Program accounts**: Contains executable bytecode or the address of a
      [program data account](/developers/docs/core/accounts/account-types#program-data-accounts)
      that stores the bytecode.
    - **Data accounts**: Contains program-defined state data. The owning program
      defines the serialization format.

    Reading account data requires two steps:

    1. Fetch the account by its [address](#account-address).
    2. Deserialize the `data` field from raw bytes into the program-defined data
       structure.

    In the examples, the mint's 82 bytes hold its authorities, supply, and
    decimals. The Token Program's 36 bytes hold a 4-byte `Program` tag and the
    address of the program data account that stores its bytecode.

    ```rust title="Account Examples" focus={4,8,14,18}
    // Example Token Mint Account
    Account {
        lamports: 1066800,
        data.len: 82,
        owner: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb,
        executable: false,
        rent_epoch: 18446744073709551615,
        data: 010000001e213c90625a7e643d9555bb01b6c3fe6416d7afd523ce8c7ddd9b923ceafb9d00000000000000000901010000001e213c90625a7e643d9555bb01b6,
    }

    // Example Token Program Account
    Account {
        lamports: 230130698,
        data.len: 36,
        owner: BPFLoaderUpgradeab1e11111111111111111111111,
        executable: true,
        rent_epoch: 18446744073709551615,
        data: 0200000027f190b1d3af98b8ce714c44e8cadff9f8fc45cb8e5fac4202eff8110d97dd37,
    }
    ```
  </Step>

  <Step title="Owner">
    The `owner` field contains the program ID (public key) of the program that owns
    this account.

    The owner program is the only program that can:

    - Modify the account's `data` field
    - Deduct lamports from the account's `lamports` field

    Any program can add lamports to another account, but only the owner can deduct
    lamports from it.

    For program accounts, the owner is the account's
    [loader program](/developers/docs/core/programs/builtin-programs#loader-programs).

    ```rust title="Account Examples" focus={5,15}
    // Example Token Mint Account
    Account {
        lamports: 1066800,
        data.len: 82,
        owner: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb,
        executable: false,
        rent_epoch: 18446744073709551615,
        data: 010000001e213c90625a7e643d9555bb01b6c3fe6416d7afd523ce8c7ddd9b923ceafb9d00000000000000000901010000001e213c90625a7e643d9555bb01b6,
    }

    // Example Token Program Account
    Account {
        lamports: 230130698,
        data.len: 36,
        owner: BPFLoaderUpgradeab1e11111111111111111111111,
        executable: true,
        rent_epoch: 18446744073709551615,
        data: 0200000027f190b1d3af98b8ce714c44e8cadff9f8fc45cb8e5fac4202eff8110d97dd37,
    }
    ```
  </Step>

  <Step title="Executable">
    The `executable` field is a boolean that determines whether the account is a
    [program account](/developers/docs/core/accounts/account-types#program-accounts) or a
    [data account](/developers/docs/core/accounts/account-types#data-accounts):

    - `true` = program account (contains executable code)
    - `false` = data account (stores state)

    ```rust title="Account Examples" focus={6,16}
    // Example Token Mint Account
    Account {
        lamports: 1066800,
        data.len: 82,
        owner: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb,
        executable: false,
        rent_epoch: 18446744073709551615,
        data: 010000001e213c90625a7e643d9555bb01b6c3fe6416d7afd523ce8c7ddd9b923ceafb9d00000000000000000901010000001e213c90625a7e643d9555bb01b6,
    }

    // Example Token Program Account
    Account {
        lamports: 230130698,
        data.len: 36,
        owner: BPFLoaderUpgradeab1e11111111111111111111111,
        executable: true,
        rent_epoch: 18446744073709551615,
        data: 0200000027f190b1d3af98b8ce714c44e8cadff9f8fc45cb8e5fac4202eff8110d97dd37,
    }
    ```
  </Step>

  <Step title="Rent epoch">
    **The `rent_epoch` field is deprecated.**

    Previously tracked when an account would automatically have lamports deducted to
    pay for maintaining its data onchain. Since ongoing rent collection is disabled,
    `rent_epoch` is set to `u64::MAX` for all new accounts that meet the minimum
    storage balance.

    ```rust title="Account Examples" focus={7,17}
    // Example Token Mint Account
    Account {
        lamports: 1066800,
        data.len: 82,
        owner: TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb,
        executable: false,
        rent_epoch: 18446744073709551615,
        data: 010000001e213c90625a7e643d9555bb01b6c3fe6416d7afd523ce8c7ddd9b923ceafb9d00000000000000000901010000001e213c90625a7e643d9555bb01b6,
    }

    // Example Token Program Account
    Account {
        lamports: 230130698,
        data.len: 36,
        owner: BPFLoaderUpgradeab1e11111111111111111111111,
        executable: true,
        rent_epoch: 18446744073709551615,
        data: 0200000027f190b1d3af98b8ce714c44e8cadff9f8fc45cb8e5fac4202eff8110d97dd37,
    }
    ```
  </Step>
</Steps>
