metaplex-foundation / js

A JavaScript SDK for interacting with Metaplex's programs
357 stars 182 forks source link

Feature Request: Create Fungible Token with metadata #247

Closed cprcrack closed 2 years ago

cprcrack commented 2 years ago

I can easily create an NFT with accompanying metadata like this:

const task = metaplex.nfts().create({ uri: '...', name: '...', ... });
const output = await task.run();

Is there an equivalent easy way for FTs (fungible tokens) that use the new Metaplex Fungible Token Metadata standard as per https://github.com/solana-labs/token-list ?

I was looking for something like metaplex.tokens().create() and I have found that there is a createMint() and createToken() method but none of those accept a uri, name etc. where I can define the on-chain and off-chain metadata. Does something like this exist or could this be added as a new feature to the tokens() module so that it is consistent with the nfts() module?

lorisleiva commented 2 years ago

Hi there 👋

Yes, that's possible.

It's not documented yet (working on it) but at least we now have API references for most of the SDK modules.

Here's the operation you're looking for: https://metaplex-foundation.github.io/js/classes/js.NftClient.html#createSft

cprcrack commented 2 years ago

That's great news! So the concept of an SFT in the SDK encompasses the FungibleAsset and Fungible token standards described here, with the only difference being the decimals being 0 or >0?

I find that difference a little bit confusing, what if I want to create a Fungible token with 0 decimals (image a currency with no decimals), I will actually be creating something that is identified as a FungibleAsset? Why is there a distinction? Is it basically only terminology, or is there an actual difference in the implementation of createSft() depending on the decimals parameter?

The new JS SDK is looking awesome by the way :)

lorisleiva commented 2 years ago

Thanks!

Yes, it's a bit confusing but all that standard is doing on-chain is checking the decimals to distinguish between SFTs that are fractionals and those who are not. That way, apps, wallets, marketplaces, etc. can interpret the JSON metadata of these SFTs slightly differently.

In practice, though it doesn't make that much difference. The most significant difference is between NFTs and SFTs as the edition accounts ensure the non-fungibility of the token. That's why the SDK only separate these two use cases and if you need more distinction you can use mySft.mint.decimals or mySft.tokenStandard.