41 min read
This guide is available in Solana Web3.js (Legacy v 1.x) and Solana Kit (v 2.x) versions. Select the appropriate tab to view the code snippets and instructions for your preferred library:
- Solana Web3.js (Legacy)
- Solana Kit
Overview
The Solana Token-2022 Program introduced powerful extensions that enhance token functionality beyond the original SPL Token program. One of these extensions is the Scaled UI Amount, which allows token issuers to define a multiplier that affects how token balances are displayed to users without changing the underlying raw amounts stored on-chain. This extension enables powerful use cases, including:
- Stock splits and reverse stock splits
- Yield-bearing tokens that visually accumulate interest
- Dividends and distributions
- Rebasing tokens that adjust the total supply
In order to build with the Scaled UI Amount extension, developers need to understand how it works and how to implement it in their applications. This guide will walk you through the process of creating a token with the Scaled UI Amount extension, minting tokens, transferring them, and updating the UI amount multiplier to see how it affects the displayed balances.
In this guide, we'll build a complete demonstration script that:
- Creates a Token-2022 token with the Scaled UI Amount extension
- Mints tokens to a holder
- Transfers tokens between accounts
- Updates the UI multiplier
- Shows how the UI amount changes while raw balances remain consistent
- Mint and transfer additional tokens to observe the effects of the updated multiplier
The end goal will be to generate a summary table that clearly shows the relationship between raw and UI amounts at each step of the demonstration:
=== DEMONSTRATION SUMMARY ===
┌─────────┬───────────────────────────┬──────────────┬────────────┬─────────────┬────────────┐
│ (index) │ Step │ Timestamp │ Multiplier │ Raw Balance │ UI Balance │
├─────────┼───────────────────────────┼──────────────┼────────────┼─────────────┼────────────┤
│ 0 │ 'Initial Setup' │ '3:02:16 PM' │ 1 │ 'n/a' │ 'n/a' │
│ 1 │ 'After Initial Mint' │ '3:02:17 PM' │ 1 │ '100000000' │ '100' │
│ 2 │ 'After Transfer #1' │ '3:02:18 PM' │ 1 │ '90000000' │ '90' │
│ 3 │ 'After Multiplier Update' │ '3:02:19 PM' │ 2 │ '90000000' │ '180' │
│ 4 │ 'After Second Mint' │ '3:02:20 PM' │ 2 │ '190000000' │ '380' │
│ 5 │ 'After Transfer #2' │ '3:02:21 PM' │ 2 │ '180000000' │ '360' │
└─────────┴───────────────────────────┴──────────────┴────────────┴─────────────┴────────────┘
Let's get started!
Prerequisites
Before starting this tutorial, ensure you have:
- Node.js (v22 or later)
- Solana CLI v 2.2.x or greater (Note: if you already have an older version, you can update it with
agave-install init 2.2.14or whichever is the latest version) - Basic understanding of Solana and TypeScript
- Familiarity with the Solana Token-2022 program and SPL Token concepts
Understanding Scaled UI Amount Extension
Before diving into the implementation, let's understand what the Scaled UI Amount extension is and how it works. The Scaled UI Amount extension defines a multiplier that is applied to the raw amount of tokens to determine the UI amount displayed to users. This allows for flexible token economics without changing the underlying raw amounts.