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

# Scaled UI Amount Issuer Guide

> Learn how to use the Scaled UI Amount extension to scale the UI amount of a token.

## How to use the Scaled UI Amount extension

To use the Scaled UI Amount extension, enable it on a token mint by initializing
the `ScaledUiAmountConfig` extension (the multiplier authority and the initial
multiplier) before `InitializeMint`. Note that once a token is created, you
cannot modify which extensions are enabled.

The TypeScript examples come in two variants. `Web3.js v3` uses the class-based
`@solana/web3.js` v3 API with `@solana-program/token-2022` instruction builders;
`Web3.js (legacy)` uses `@solana/web3.js` v1 with `@solana/spl-token`.

The steps below build on each other:

- The CLI commands use your Solana CLI wallet and cluster, and take the mint
  address that `create-token` prints (`66EV…` in these examples).
- The TypeScript snippets are one script that runs on devnet. Each step reuses
  `connection`, `payer`, and `mint` (and the helper functions) from the steps
  before it, so put them in one file and merge the imports. The fee payer is the
  Solana CLI wallet at `~/.config/solana/id.json`; fund it with devnet SOL from
  the [Solana faucet](https://faucet.solana.com) first.

### Enable the Scaled UI Amount extension on a token mint

To enable the Scaled UI Amount extension, add the `ScaledUiAmountConfig`
extension when you create the mint: allocate space for it, initialize it with
`InitializeScaledUiAmountMint` (authority and initial multiplier), then
initialize the mint, all in one transaction. With the `spl-token` CLI, pass
`--ui-amount-multiplier` to `create-token`:

<CodeGroup>

```console create-token.sh
$ spl-token --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb create-token --ui-amount-multiplier 1.5
Creating token 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM under program TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb

Address:  66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM
Decimals:  9

Signature: 2sPziXu9M3duTCvsDvxQE9UKC9nBiLayi8muDvnjhA2qYvfXSZuaUieoq39MFjg4kf8xFrw6crmYSkPyV59dvudF
```

```ts title="Web3.js v3"
import { readFileSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import {
  Connection,
  Keypair,
  PublicKey,
  SystemProgram,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import {
  getInitializeMint2Instruction,
  getInitializeScaledUiAmountMintInstruction,
  getMintSize,
  TOKEN_2022_PROGRAM_ADDRESS
} from "@solana-program/token-2022";

/**
 * Creates a new SPL-Token 2022 mint with the Scaled UI extension enabled
 * and a UI multiplier of 1.1.
 *
 * @param connection – An initialized Solana Connection.
 * @param payer      – Signer paying for fees and rent.
 * @returns The newly created mint PublicKey.
 */
export async function createScaledUiMint(
  connection: Connection,
  payer: Keypair
): Promise<PublicKey> {
  // 1) Generate a new mint Keypair
  const mint = await Keypair.generate();
  const mintLen = getMintSize([
    {
      __kind: "ScaledUiAmountConfig",
      authority: payer.publicKey.toBase58(),
      multiplier: 1.1,
      newMultiplierEffectiveTimestamp: 0n,
      newMultiplier: 1.1
    }
  ]);
  const mintLamports =
    await connection.getMinimumBalanceForRentExemption(mintLen);
  const mintTransaction = new Transaction().add(
    SystemProgram.createAccount({
      fromPubkey: payer.publicKey,
      newAccountPubkey: mint.publicKey,
      space: mintLen,
      lamports: mintLamports,
      programId: new PublicKey(TOKEN_2022_PROGRAM_ADDRESS)
    }),
    getInitializeScaledUiAmountMintInstruction({
      mint: mint.publicKey,
      authority: payer.publicKey.toBase58(),
      multiplier: 1.1
    }),
    getInitializeMint2Instruction({
      mint: mint.publicKey,
      decimals: 0,
      mintAuthority: payer.publicKey.toBase58(),
      freezeAuthority: null
    })
  );
  await sendAndConfirmTransaction(
    connection,
    mintTransaction,
    [payer, mint],
    undefined
  );

  console.log(
    "✅ Created mint w/ scaled-UI extension:",
    mint.publicKey.toBase58()
  );
  return mint.publicKey;
}

// 1) Connect to devnet
const connection = new Connection("https://api.devnet.solana.com", "confirmed");

// 2) Load the Solana CLI wallet as the fee payer and mint authority. Fund it
//    with devnet SOL from https://faucet.solana.com first.
const payer = await Keypair.fromSecretKey(
  Uint8Array.from(
    JSON.parse(
      readFileSync(join(homedir(), ".config/solana/id.json"), "utf8")
    )
  )
);

// 3) Create the scaled-UI mint using our helper
const mint = await createScaledUiMint(connection, payer);
```

<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 { readFileSync } from "node:fs";
import { homedir } from "node:os";
import { join } from "node:path";
import {
  Connection,
  Keypair,
  PublicKey,
  type Signer,
  SystemProgram,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import {
  TOKEN_2022_PROGRAM_ID,
  createInitializeMintInstruction,
  createInitializeScaledUiAmountConfigInstruction,
  ExtensionType,
  getMintLen
} from "@solana/spl-token";

/**
 * Creates a new SPL-Token 2022 mint with the Scaled UI extension enabled
 * and a UI multiplier of 1.1.
 *
 * @param connection – An initialized Solana Connection.
 * @param payer      – Signer paying for fees and rent.
 * @returns The newly created mint PublicKey.
 */
export async function createScaledUiMint(
  connection: Connection,
  payer: Signer
): Promise<PublicKey> {
  // 1) Generate a new mint Keypair
  const mint = Keypair.generate();
  const MINT_EXTENSIONS = [ExtensionType.ScaledUiAmountConfig];
  const mintLen = getMintLen(MINT_EXTENSIONS);
  const mintLamports =
    await connection.getMinimumBalanceForRentExemption(mintLen);
  const mintTransaction = new Transaction().add(
    SystemProgram.createAccount({
      fromPubkey: payer.publicKey,
      newAccountPubkey: mint.publicKey,
      space: mintLen,
      lamports: mintLamports,
      programId: TOKEN_2022_PROGRAM_ID
    }),
    createInitializeScaledUiAmountConfigInstruction(
      mint.publicKey,
      payer.publicKey,
      1.1,
      TOKEN_2022_PROGRAM_ID
    ),
    createInitializeMintInstruction(
      mint.publicKey,
      0,
      payer.publicKey,
      null,
      TOKEN_2022_PROGRAM_ID
    )
  );
  await sendAndConfirmTransaction(
    connection,
    mintTransaction,
    [payer, mint],
    undefined
  );

  console.log(
    "✅ Created mint w/ scaled-UI extension:",
    mint.publicKey.toBase58()
  );
  return mint.publicKey;
}

// 1) Connect to devnet
const connection = new Connection("https://api.devnet.solana.com", "confirmed");

// 2) Load the Solana CLI wallet as the fee payer and mint authority. Fund it
//    with devnet SOL from https://faucet.solana.com first.
const payer = Keypair.fromSecretKey(
  Uint8Array.from(
    JSON.parse(
      readFileSync(join(homedir(), ".config/solana/id.json"), "utf8")
    )
  )
);

// 3) Create the scaled-UI mint using our helper
const mint = await createScaledUiMint(connection, payer);
```

</CodeGroup>

### Create a token account and mint tokens

The balance in the last step needs a token account that holds tokens. Create the
mint authority's associated token account for the new mint and mint 100 tokens
to it.

<CodeGroup>

```bash mint-tokens.sh
spl-token create-account 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM
spl-token mint 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM 100
```

```ts title="Web3.js v3"
import {
  Connection,
  Keypair,
  PublicKey,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import {
  findAssociatedTokenPda,
  getCreateAssociatedTokenIdempotentInstruction,
  getMintToCheckedInstruction,
  TOKEN_2022_PROGRAM_ADDRESS
} from "@solana-program/token-2022";

/**
 * Creates the owner's associated token account for the mint and mints tokens
 * to it.
 *
 * @param connection – An initialized Solana Connection.
 * @param payer      – Mint authority, fee payer, and token account owner.
 * @param mint       – PublicKey of the mint.
 * @param amount     – Amount to mint, in base units.
 * @returns The token account address.
 */
export async function mintScaledUiTokens(
  connection: Connection,
  payer: Keypair,
  mint: PublicKey,
  amount: bigint
): Promise<PublicKey> {
  const [tokenAccount] = await findAssociatedTokenPda({
    mint: mint.toBase58(),
    owner: payer.publicKey.toBase58(),
    tokenProgram: TOKEN_2022_PROGRAM_ADDRESS
  });

  const transaction = new Transaction().add(
    getCreateAssociatedTokenIdempotentInstruction({
      payer,
      ata: tokenAccount,
      owner: payer.publicKey,
      mint
    }),
    getMintToCheckedInstruction({
      mint,
      token: tokenAccount,
      mintAuthority: payer,
      amount,
      decimals: 0
    })
  );
  await sendAndConfirmTransaction(connection, transaction, [payer], undefined);

  console.log(`✅ Minted ${amount} tokens to:`, tokenAccount);
  return new PublicKey(tokenAccount);
}
const tokenAccount = await mintScaledUiTokens(connection, payer, mint, 100n);
```

<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 {
  Connection,
  PublicKey,
  type Signer,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import {
  TOKEN_2022_PROGRAM_ID,
  createAssociatedTokenAccountIdempotentInstruction,
  createMintToCheckedInstruction,
  getAssociatedTokenAddressSync
} from "@solana/spl-token";

/**
 * Creates the owner's associated token account for the mint and mints tokens
 * to it.
 *
 * @param connection – An initialized Solana Connection.
 * @param payer      – Mint authority, fee payer, and token account owner.
 * @param mint       – PublicKey of the mint.
 * @param amount     – Amount to mint, in base units.
 * @returns The token account address.
 */
export async function mintScaledUiTokens(
  connection: Connection,
  payer: Signer,
  mint: PublicKey,
  amount: bigint
): Promise<PublicKey> {
  const tokenAccount = getAssociatedTokenAddressSync(
    mint,
    payer.publicKey,
    false,
    TOKEN_2022_PROGRAM_ID
  );

  const transaction = new Transaction().add(
    createAssociatedTokenAccountIdempotentInstruction(
      payer.publicKey,
      tokenAccount,
      payer.publicKey,
      mint,
      TOKEN_2022_PROGRAM_ID
    ),
    createMintToCheckedInstruction(
      mint,
      tokenAccount,
      payer.publicKey,
      amount,
      0,
      [],
      TOKEN_2022_PROGRAM_ID
    )
  );
  await sendAndConfirmTransaction(connection, transaction, [payer], undefined);

  console.log(`✅ Minted ${amount} tokens to:`, tokenAccount.toBase58());
  return tokenAccount;
}
const tokenAccount = await mintScaledUiTokens(connection, payer, mint, 100n);
```

</CodeGroup>

### Update the UI amount multiplier

To update the UI amount multiplier, you need to use the
`update-ui-amount-multiplier` command. A timestamp, in seconds since the Unix
epoch, is optional and can be used to set a custom start time for the new
multiplier. If no timestamp is provided, the current timestamp will be used.

<Info>
  Token-2022 releases before v10 had a bug: if a scheduled multiplier had
  already taken effect, setting the next one overwrote it instead of making it
  the current multiplier, so issuers re-sent the previous multiplier first.
  [PR #522](https://github.com/solana-program/token-2022/pull/522) fixed this.
  Token-2022 v10 and later, the version on mainnet and devnet, makes the
  pending multiplier current before storing the new one, so one update is
  enough.
</Info>

<CodeGroup>

```bash update-ui-amount-multiplier.sh
# Takes effect now
spl-token update-ui-amount-multiplier 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM 2
# Takes effect at a Unix timestamp (2030-01-01 00:00:00 UTC)
spl-token update-ui-amount-multiplier 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM 3 -- 1893456000
```

```ts title="Web3.js v3"
import {
  Connection,
  Keypair,
  PublicKey,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import { getUpdateMultiplierScaledUiMintInstruction } from "@solana-program/token-2022";

/**
 * Updates the scaled UI multiplier for an existing SPL-Token 2022 mint.
 *
 * @param connection         – An initialized Solana Connection.
 * @param payer              – Multiplier authority, also paying the fees.
 * @param mint               – PublicKey of the mint to update.
 * @param multiplier         – New multiplier value to set.
 * @param effectiveTimestamp – Unix timestamp (seconds) when it takes effect.
 * @returns The transaction signature.
 */
export async function updateScaledUiMultiplier(
  connection: Connection,
  payer: Keypair,
  mint: PublicKey,
  multiplier: number,
  effectiveTimestamp: bigint
): Promise<string> {
  const transaction = new Transaction().add(
    getUpdateMultiplierScaledUiMintInstruction({
      mint,
      authority: payer,
      multiplier,
      effectiveTimestamp
    })
  );

  const signature = await sendAndConfirmTransaction(
    connection,
    transaction,
    [payer],
    undefined
  );

  console.log(
    `✅ Updated scaled-UI multiplier to ${multiplier} for mint:`,
    mint.toBase58()
  );
  return signature;
}
const multiplier = 1.5;
const effectiveTimestamp = BigInt(Math.floor(Date.now() / 1000));
const updateSignature = await updateScaledUiMultiplier(
  connection,
  payer,
  mint,
  multiplier,
  effectiveTimestamp
);
console.log("Update signature:", updateSignature);
```

<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 {
  Connection,
  PublicKey,
  type Signer,
  Transaction,
  sendAndConfirmTransaction
} from "@solana/web3.js";
import {
  TOKEN_2022_PROGRAM_ID,
  createUpdateMultiplierDataInstruction
} from "@solana/spl-token";

/**
 * Updates the scaled UI multiplier for an existing SPL-Token 2022 mint.
 *
 * @param connection         – An initialized Solana Connection.
 * @param payer              – Multiplier authority, also paying the fees.
 * @param mint               – PublicKey of the mint to update.
 * @param multiplier         – New multiplier value to set.
 * @param effectiveTimestamp – Unix timestamp (seconds) when it takes effect.
 * @returns The transaction signature.
 */
export async function updateScaledUiMultiplier(
  connection: Connection,
  payer: Signer,
  mint: PublicKey,
  multiplier: number,
  effectiveTimestamp: bigint
): Promise<string> {
  const transaction = new Transaction().add(
    createUpdateMultiplierDataInstruction(
      mint,
      payer.publicKey,
      multiplier,
      effectiveTimestamp,
      [],
      TOKEN_2022_PROGRAM_ID
    )
  );

  const signature = await sendAndConfirmTransaction(
    connection,
    transaction,
    [payer],
    undefined
  );

  console.log(
    `✅ Updated scaled-UI multiplier to ${multiplier} for mint:`,
    mint.toBase58()
  );
  return signature;
}
const multiplier = 1.5;
const effectiveTimestamp = BigInt(Math.floor(Date.now() / 1000));
const updateSignature = await updateScaledUiMultiplier(
  connection,
  payer,
  mint,
  multiplier,
  effectiveTimestamp
);
console.log("Update signature:", updateSignature);
```

</CodeGroup>

### Fetch the Balance

To fetch the balance, you need to use the `balance` command. The balance is the
raw amount multiplied by the current multiplier: after the CLI steps above, 100
tokens at a multiplier of 2 show as 200, and the TypeScript script prints 150
(100 tokens at 1.5).

<CodeGroup>

```bash balance.sh
spl-token balance 66EV4CaihdqyQ1fbsr51wBsoqKLgAG5KiYz7r5XNrxUM
```

```ts title="Web3.js v3"
import { Connection, PublicKey } from "@solana/web3.js";
import {
  findAssociatedTokenPda,
  TOKEN_2022_PROGRAM_ADDRESS
} from "@solana-program/token-2022";

/**
 * Gets the scaled UI amount balance for a token holder.
 *
 * @param connection – An initialized Solana Connection.
 * @param mint       – PublicKey of the mint to check.
 * @param owner      – PublicKey of the token holder.
 * @returns The scaled UI amount balance.
 */
export async function getScaledUiAmountBalance(
  connection: Connection,
  mint: PublicKey,
  owner: PublicKey
): Promise<number> {
  // Get the token account for this mint/owner pair
  const [tokenAccount] = await findAssociatedTokenPda({
    mint: mint.toBase58(),
    owner: owner.toBase58(),
    tokenProgram: TOKEN_2022_PROGRAM_ADDRESS
  });

  // Get the token account info
  const accountInfo = await connection.getAccountInfo(
    new PublicKey(tokenAccount)
  );
  if (!accountInfo) {
    throw new Error("Token account not found");
  }

  const info = await connection.getTokenAccountBalance(
    new PublicKey(tokenAccount)
  );
  if (info.value.uiAmount == null) throw new Error("No balance found");
  console.log("Balance: ", info.value.uiAmount);
  return info.value.uiAmount;
}
const balance = await getScaledUiAmountBalance(connection, mint, payer.publicKey);
```

<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 { Connection, PublicKey } from "@solana/web3.js";
import {
  TOKEN_2022_PROGRAM_ID,
  getAssociatedTokenAddressSync
} from "@solana/spl-token";

/**
 * Gets the scaled UI amount balance for a token holder.
 *
 * @param connection – An initialized Solana Connection.
 * @param mint       – PublicKey of the mint to check.
 * @param owner      – PublicKey of the token holder.
 * @returns The scaled UI amount balance.
 */
export async function getScaledUiAmountBalance(
  connection: Connection,
  mint: PublicKey,
  owner: PublicKey
): Promise<number> {
  // Get the token account for this mint/owner pair
  const tokenAccount = getAssociatedTokenAddressSync(
    mint,
    owner,
    false,
    TOKEN_2022_PROGRAM_ID
  );

  // Get the token account info
  const accountInfo = await connection.getAccountInfo(tokenAccount);
  if (!accountInfo) {
    throw new Error("Token account not found");
  }

  const info = await connection.getTokenAccountBalance(tokenAccount);
  if (info.value.uiAmount == null) throw new Error("No balance found");
  console.log("Balance: ", info.value.uiAmount);
  return info.value.uiAmount;
}
const balance = await getScaledUiAmountBalance(connection, mint, payer.publicKey);
```

</CodeGroup>
