js icon indicating copy to clipboard operation
js copied to clipboard

Cannot mint SPL tokens with large initial supply

Open joaquim-verges opened this issue 2 years ago • 1 comments
trafficstars

in this line: https://github.com/metaplex-foundation/js/blob/main/packages/js/src/plugins/tokenModule/operations/mintTokens.ts#L257

it's converting a BN to JS Number which can only store 53 bits, not nearly enough for large amount of tokens with 9 decimals.

Result is that you cannot mint tokens with an initial supply of say 10M tokens.

Same issue happens when calling the utility function token("10000000", 9).

joaquim-verges avatar Dec 02 '22 02:12 joaquim-verges

Hi there 👋

Thanks for raising this.

In the code snippet shared, it seems like createMintToInstruction from @solana/spl-token only expects the type number which is why I'm converting it from a BN.

I'm working on a solution that involves more interfaces and would fix this in the long term but I'm afraid for now the solution would be to create this instruction manually.

lorisleiva avatar Dec 12 '22 08:12 lorisleiva