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

# ERC20 on Solana: The Token Program

> Map ERC20 to Solana's Token Program: mint accounts, token accounts, transfers, approvals, and Token Extensions, with @solana/kit examples.

On Ethereum, every ERC20 token is its own contract. On Solana, a shared token
program runs every fungible token, and a new token is a new account. This guide
maps each ERC20 function to its Solana equivalent.

## How tokens work on Solana

ERC20 is an interface. Each token deploys a contract that implements it and
stores every holder's balance in that contract. Solana takes the opposite
approach: the [Token Program](/developers/docs/tokens) is deployed once, and it
stores each token and each balance in separate accounts.

```mermaid
flowchart TD
    C["ERC20 contract<br/>One contract per token."]
    C -->|holds| C0["Code<br/>transfer, approve, transferFrom"]
    C -->|holds| C1["Storage<br/>Name, symbol, decimals, balances, allowances"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="18efa40e311d">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/18efa40e311d-light.svg" alt="On Ethereum, an ERC20 contract holds every balance." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/18efa40e311d.svg" alt="On Ethereum, an ERC20 contract holds every balance." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/18efa40e311d-sm-light.svg" alt="On Ethereum, an ERC20 contract holds every balance." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/18efa40e311d-sm.svg" alt="On Ethereum, an ERC20 contract holds every balance." />
</div>

<p className="sol-caption">On Ethereum, an ERC20 contract holds every balance.</p>

```mermaid
flowchart TD
    P["Token Program<br/>Deployed once, shared by every token"]
    P -->|owns| P0["Mint account<br/>Supply, decimals, authorities"]
    P -->|owns| P1["Token account<br/>Alice's balance"]
    P -->|owns| P2["Token account<br/>Bob's balance"]
```

<div className="sol-mermaid" data-fallback="mermaid" data-mermaid="36ca8c5b158d">
  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/36ca8c5b158d-light.svg" alt="On Solana, the Token Program keeps each balance in its own account." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/36ca8c5b158d.svg" alt="On Solana, the Token Program keeps each balance in its own account." />

  <img className="block dark:hidden" src="/docs-assets/assets/docs/mermaid/36ca8c5b158d-sm-light.svg" alt="On Solana, the Token Program keeps each balance in its own account." />

  <img className="hidden dark:block" src="/docs-assets/assets/docs/mermaid/36ca8c5b158d-sm.svg" alt="On Solana, the Token Program keeps each balance in its own account." />
</div>

<p className="sol-caption">On Solana, the Token Program keeps each balance in its own account.</p>

Three account types replace the contract:

- A **mint account** represents one token. Its address, the mint address,
  identifies the token the way a contract address does on Ethereum. It stores
  the supply, the decimals, and the mint and freeze authorities.
- A **token account** holds one owner's balance of one mint.
- An **associated token account (ATA)** is a token account at an address derived
  from the owner, the mint, and the mint's token program, so anyone can compute
  where a wallet holds a given token.

Solana has two token programs. The original Token Program covers minting,
transfers, and delegates. The Token Extensions Program, also called Token-2022,
includes the same instructions and adds optional features per mint.

## Create a token

You create a token by sending transactions to the Token Program. You write no
contract and deploy nothing. With the `spl-token` CLI, three commands create a
mint, create your token account, and mint 100 tokens:

```bash Terminal
spl-token create-token
spl-token create-account <MINT_ADDRESS>
spl-token mint <MINT_ADDRESS> 100
```

| Step | Ethereum (ERC20) | Solana (Token Program) |
| --- | --- | --- |
| Write the token | Write or import a Solidity contract, often from OpenZeppelin. | Nothing to write. The Token Program is already deployed. |
| Deploy | Compile and deploy the contract. The contract address identifies the token. | Create a mint account. The mint address identifies the token. |
| Mint supply | Call the constructor or a `mint` function. | The mint authority sends a mint instruction to a token account. |
| Receive | Any address can hold a balance in the contract's storage. | The recipient needs a token account for the mint. The sender can create it in the same transaction. |
| Change behavior | Upgrade through a proxy or deploy a new contract. | Enable extensions when you create the mint, or write a separate program. |
| Audit | Each token contract needs its own review. | Every token runs one of two audited token programs. A transfer hook program is custom code and needs its own review. |

## ERC20 functions on Solana

Each ERC20 function maps to a field you read from an account or an instruction
you send to the Token Program.

| ERC20 | Solana | How it maps |
| --- | --- | --- |
| `name()`, `symbol()` | Token metadata | Read the name and symbol from the token's metadata, stored in a Metaplex metadata account or on the mint with the metadata extension. |
| `decimals()` | Mint account field | Read `decimals` from the mint account. |
| `totalSupply()` | Mint account field | Read `supply` from the mint account. |
| `balanceOf()` | Token account amount | Derive the owner's associated token account for the mint and read its amount. A missing account means a balance of 0. To include other token accounts the owner holds, use `getTokenAccountsByOwner`. |
| `transfer()` | `TransferChecked` | Move tokens between two token accounts of the same mint. The owner signs. |
| `approve()` | `ApproveChecked` | Set one delegate and a delegated amount on a token account. |
| `transferFrom()` | `TransferChecked` signed by the delegate | The delegate signs the same transfer instruction and spends from its delegated amount. |
| `allowance()` | Token account fields | Read `delegate` and `delegated_amount` from the token account. |

## Read token data

ERC20 view functions become account reads. Fetch the mint account for the
decimals and supply, and fetch the owner's associated token account for the
balance. This example uses `@solana/kit` and `@solana-program/token` with a mint
under the original Token Program. For a Token Extensions mint, pass that
program's address as `tokenProgram`. The mint account's owner tells you which
program it uses.

```ts
import { address, createSolanaRpc } from "@solana/kit";
import {
  fetchMint,
  findAssociatedTokenPda,
  TOKEN_PROGRAM_ADDRESS,
} from "@solana-program/token";

const rpc = createSolanaRpc("https://api.devnet.solana.com");
const mint = address("<MINT_ADDRESS>");
const owner = address("<WALLET_ADDRESS>");

// decimals() and totalSupply()
const { data } = await fetchMint(rpc, mint);
console.log(data.decimals, data.supply);

// balanceOf(owner)
const [tokenAccount] = await findAssociatedTokenPda({
  owner,
  mint,
  tokenProgram: TOKEN_PROGRAM_ADDRESS,
});
const { value } = await rpc.getTokenAccountBalance(tokenAccount).send();
console.log(value.amount);
```

The name and symbol are not fields of the mint. A token stores them in one of
two places: a [Metaplex Token Metadata](/developers/docs/tokens/metaplex)
account linked to the mint, or the [metadata
extension](/developers/docs/tokens/extensions/metadata) on a Token Extensions
mint. For a mint that uses Metaplex metadata:

```ts
import { fetchMetadataFromSeeds } from "@metaplex-foundation/mpl-token-metadata-kit";

// name() and symbol()
const metadata = await fetchMetadataFromSeeds(rpc, { mint });
console.log(metadata.data.name, metadata.data.symbol);
```

## Transfer tokens

A transfer moves tokens from the sender's token account to the recipient's token
account. Both accounts must exist, so a transfer to a new holder usually carries
two instructions in one transaction.

<Steps>
<Step title="Derive the token accounts">

Compute the sender's and recipient's associated token accounts from each owner
and the mint.

</Step>
<Step title="Create the recipient's account">

Add an idempotent create instruction. It does nothing if the account exists. If
it does not, the payer funds the rent deposit, a refundable SOL balance that
pays for the account's storage.

</Step>
<Step title="Transfer">

Add `TransferChecked`, which verifies the mint and decimals before it moves
tokens.

</Step>
<Step title="Send one transaction">

Both instructions succeed or fail together.

</Step>
</Steps>

```ts
const [source] = await findAssociatedTokenPda({
  owner: sender.address,
  mint,
  tokenProgram: TOKEN_PROGRAM_ADDRESS,
});
const [destination] = await findAssociatedTokenPda({
  owner: recipient,
  mint,
  tokenProgram: TOKEN_PROGRAM_ADDRESS,
});

const instructions = [
  // Creates the recipient's token account only if it does not exist yet.
  getCreateAssociatedTokenIdempotentInstruction({
    payer: sender,
    ata: destination,
    owner: recipient,
    mint,
  }),
  getTransferCheckedInstruction({
    source,
    mint,
    destination,
    authority: sender,
    amount: 1_000_000n, // 1 token with 6 decimals
    decimals: 6,
  }),
];
```

<Note>

**Amounts are in base units**

Instructions take integer amounts in the token's smallest unit. For a mint with
6 decimals, 1 token is `1_000_000n`. See [Transfer
tokens](/developers/docs/tokens/basics/transfer-tokens) for the code that signs
and sends the transaction.

</Note>

## Approvals and delegates

Solana has an approval model, and you need it less often. An ERC20 flow such as
a swap takes an `approve` transaction followed by a call that runs
`transferFrom`. On Solana, the user signs the transaction that calls the
program, and that signature lets the program transfer from the user's token
account in the same transaction, so most flows need no standing allowance.

When another address must spend later, for example a subscription or an escrow,
approve it as a [delegate](/developers/docs/tokens/basics/approve-delegate):

<Columns cols={2}>
<Card title="ERC20 allowance">

- One allowance per owner and spender, with any number of spenders.
- Stored in the token contract.
- Unlimited approvals are common and stay active until revoked.

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

- One delegate and one delegated amount per token account.
- Stored on the token account.
- A new approval replaces the previous delegate and amount.

</Card>
</Columns>

```ts
const approve = getApproveCheckedInstruction({
  source, // the sender's token account
  mint,
  delegate, // address allowed to spend
  owner: sender, // the token account owner signs the approval
  amount: 1_000_000n,
  decimals: 6,
});
```

The owner, or the delegate itself, removes a delegate with the
[`Revoke`](/developers/docs/tokens/basics/revoke-delegate) instruction. If a
program needs custody across several users, hold the tokens in a token account
owned by a program-derived address (PDA), an address that only the program can
sign for, instead of collecting delegations.

## Beyond ERC20: Token Extensions

ERC20 projects add features by editing the contract. On Solana, the [Token
Extensions Program](/developers/docs/tokens/extensions) ships common features as
options you enable on a mint:

<Columns cols={3}>
<Card title="Metadata" href="/developers/docs/tokens/extensions/metadata" arrow>

Store the name, symbol, and URI on the mint itself.

</Card>
<Card title="Transfer fees" href="/developers/docs/tokens/extensions/transfer-fees" arrow>

Withhold a fee on every transfer.

</Card>
<Card title="Transfer hook" href="/developers/docs/tokens/extensions/transfer-hook" arrow>

Call your own program on every transfer to enforce custom rules.

</Card>
<Card title="Permanent delegate" href="/developers/docs/tokens/extensions/permanent-delegate" arrow>

Give one authority the right to transfer or burn from any account of the mint.

</Card>
<Card title="Pausable" href="/developers/docs/tokens/extensions/pausable" arrow>

Let an authority pause transfers, minting, and burning for the mint.

</Card>
<Card title="Non-transferable" href="/developers/docs/tokens/extensions/non-transferrable-tokens" arrow>

Issue tokens that holders cannot move.

</Card>
</Columns>

<Warning>

**Choose extensions before you create the mint**

Most extensions cannot be added after an account is initialized. Decide which
ones the token needs up front.

</Warning>

## Tradeoffs

<Columns cols={2}>
<Card title="ERC20: A contract per token">

- Each token can change any behavior in its own code.
- Integrators must check that each contract follows the interface.
- Every new token is a deployment, and custom logic needs an audit.
- Indexing all tokens means tracking many contracts.

</Card>
<Card title="Token Program: Shared programs for every token">

- Tokens share one instruction set, so a basic integration works with any mint.
- A new token is a transaction, not a deployment.
- Custom behavior is limited to extensions or a separate program. Integrators
  check which extensions a mint uses, because transfer fees, transfer hooks, and
  a permanent delegate change how transfers behave.
- Each holder needs a token account per mint, funded with a rent deposit.

</Card>
</Columns>

## Next steps

<Columns cols={3}>
<Card title="Token quickstart" href="/developers/docs/tokens/quickstart" arrow>

Create and transfer a token on Devnet.

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

Map NFT collections to mints and metadata.

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

Issue permissioned tokens with Token Extensions.

</Card>
</Columns>
