js
js copied to clipboard
Candy Machine: Zero-decimal SPL Tokens
Hi there! I've been working with the candy machine plugin, and in testing, believe I've come across an issue with SPL token-based mints.
I think the library does not handle SPL tokens with varying decimals. In this instance, I have an SPL token with zero decimals, and when setting a price of 1, the resulting candy machine (through create or update methods) ends up deployed with a resulting price of 1,000,000,000
(off by a factor of 10^9).
At first I was working with the JSON based methods like createFromJsonConfig
. Since price is just a number
there I was simply providing price: 1
.
I assumed I might need to move to the lower level create
method for more control, and tried to solve this by doing:
price: token(myPrice, 0, "CUSTOM")
But alas, in both cases price came out as 1,000,000,000
.
Checked out the tests for guidance and noticed that SPL tokens are always generated with mx.tokens().createTokenWithMint()
, so I'm wondering if this is just an unexplored case.
https://github.com/metaplex-foundation/js/blob/8d2183d84f8ce4e6f383b8578f84df6cdc5d1049/packages/js/test/plugins/candyMachineModule/createCandyMachine.test.ts#L130
I also see here that the price is assumed to always be compatible with lamports()
:
https://github.com/metaplex-foundation/js/blob/8d2183d84f8ce4e6f383b8578f84df6cdc5d1049/packages/js/src/plugins/candyMachineModule/CandyMachine.ts#L139
Please let me know if I'm doing something wrong! (Also, FWIW, Sugar CLI works fine with zero-decimal tokens).