Search code examples
solanasolana-cli

When trying to mint tokens using spl-token mint, and trying to mint 1,000,000,000,000 tokens, it only mints 18446744073.709551615 tokens


Create Token: ~$ spl-token create-token Creating token 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 Signature: bmHzFBvFU2vq7AeLHuQuYsgDEPZRXV9mSDfK7RjPU7CwkyQoPEZLzrsCDaAJWB32bffmKsemjEshhrataAr2tQ8

Check Supply: ~$ spl-token supply 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 0

Mint Coins: ~$ spl-token mint 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 1000000000000 Minting 1000000000000 tokens Token: 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 Recipient: 85vRuzFU2LA2KQwpKRFF6TAwJVfJevT4GWAYVpGdfZ7U Signature: 3HDX6mRB1WBqpeSyYTwAfbobiBw8XdPa3nDTpbvSvH2cZFFMKfT8wLNV4rSHRRsWAsoDbuXULr5h94xQ8a9ZmmKk

Check Coin Supply: ~$ spl-token balance 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 18446744073.709551615

If I try to add coins to make up the missing coins, I get the following:

Error when adding coins:

~$ spl-token mint 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 100 Minting 100 tokens Token: 4PgB5jPM9a5Js5FT6zPJHD8rcDogcnbSSLS1d5Mny9n1 Recipient: 4rqoTZ2JTvdDzY5i4X73ZnGQjjPkNRpRfaByZ1anWgBD RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: custom program error: 0xe [5 log messages]

I have been following the instructions on this page: https://spl.solana.com/token. I can't find any information on this anywhere, much less any log files to look at. I'm pretty sure I'm missing something, anybody?


Solution

  • The supply of tokens in the spl-token program is given by a u64: https://github.com/solana-labs/solana-program-library/blob/28d0aa775949869a4390dece7341fbb3daeddb5d/token/program/src/state.rs#L22, which means that the maximum possible number of tokens is 18446744073709551615. If you set 9 decimals in your token, as you have done, that means that the maximum number of possible tokens is u64::MAX / 1_000_000_000, or 18446744073.709551615.

    If you need a higher number of coins, you'll have to create a new mint with fewer decimals.