How to Determine the Maximum Supply of Solana SPL Tokens

ยท

This article explains the underlying computational logic for determining Solana SPL token quantities and provides a table illustrating the relationship between token precision and maximum supply.

In digital calculations, handling decimals often leads to precision loss because computers use binary systems to store numbers, which cannot always represent decimals accurately. For example, if a product costs 0.99 USD and a customer pays 1 USD, using floating-point data types for calculations may yield imprecise results due to binary representation limitations.

Thus, financial systems typically use integers to avoid precision loss in floating-point operations.

How to Replace Floating-Point Operations with Integers?

Suppose a product costs 0.99 USD, and a customer pays 1 USD:

For display purposes, the result is adjusted for precision:

Higher precision allows for more decimal places in display.

SPL Token Precision and Supply

Solana's SPL-Token program uses u64 to store and calculate token quantities. The maximum integer u64 can represent is 18446744073709551615.

SPL tokens typically have a precision between 0 and 9.

Below is a table of precision levels and their corresponding maximum supplies:

PrecisionMaximum Supply
918446744073.709551615
8184467440737.09551615
71844674407370.9551615
618446744073709.551615
5184467440737095.51615
41844674407370955.1615
318446744073709551.615
2184467440737095516.15
11844674407370955161.5
018446744073709551615

Experimental Validation

To validate the data above, we conducted an experiment on Solana's Devnet:

  1. Create a Token with Precision 6:

    spl-token create-token --decimals 6

    Output:

    Creating token 5wYhtgLtowkvYeEXoYpCeGvdUHjqsQPvKqM1Qy6gpFSv under program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
    Address: 5wYhtgLtowkvYeEXoYpCeGvdUHjqsQPvKqM1Qy6gpFSv
    Decimals: 6
  2. Mint Tokens Up to Maximum Supply:

    spl-token mint 5wYhtgLtowkvYeEXoYpCeGvdUHjqsQPvKqM1Qy6gpFSv 18446744073709.551615

    Output:

    Minting 18446744073709.55 tokens
  3. Check Balance:

    spl-token balance 5wYhtgLtowkvYeEXoYpCeGvdUHjqsQPvKqM1Qy6gpFSv

    Output:

    18446744073709.551615
  4. Attempt to Mint Beyond Maximum Supply:

    spl-token mint 5wYhtgLtowkvYeEXoYpCeGvdUHjqsQPvKqM1Qy6gpFSv 0.000001

    Output:

    Error: Operation overflowed

The experiment confirms that 18446744073709.551615 is indeed the maximum supply for precision 6.


FAQ

Q1: What is token precision in Solana SPL tokens?
A1: Token precision refers to the number of decimal places a token can support. For example, a precision of 6 means the token can represent values up to 6 decimal places.

Q2: Why does precision affect maximum supply?
A2: Higher precision divides the u64 storage space into smaller units, reducing the maximum integer value representable without overflow.

Q3: Can I change a token's precision after creation?
A3: No, precision is immutable once the token is created.

Q4: What happens if I exceed the maximum supply?
A4: The transaction will fail with an "Operation overflowed" error.

๐Ÿ‘‰ Learn more about Solana token standards

๐Ÿ‘‰ Explore advanced tokenomics strategies