1

I have 2 instruction. the goal is to create new SPL token, 1,000,000 initial supply with 6 decimal precision.

const initializeMintIx = createInitializeMintInstruction(
  mint.publicKey,
  6, // decimal come from text input
  owner, // mint authority
  owner, // freeze authority
  TOKEN_2022_PROGRAM_ID,
);

const mintToIx = createMintToInstruction(
  mint.publicKey,
  tokenAccount,
  owner,
  1_000_000, // amount. I'm confused on this number
  [],
  TOKEN_2022_PROGRAM_ID,
);

what number should I put on amount in createMintToInstruction param? my current formula for amount is:

tokenSupply * (10 ** tokenDecimal)

enter image description here

is this the correct formula?

I'm trying to fix this: Circulating supply wrong on solana fm?. maybe there's something wrong on my amount formula. thx

1 Answer 1

1

Yep you have it correct! Just be careful about using a number that can be properly represented by a JS number, which is 9007199254740991.

More info at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.