Skip to content

​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 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:

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

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

​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).