metaplex-foundation / js

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

Proposal: Improve token create / update #317

Closed GM-Alex closed 1 year ago

GM-Alex commented 1 year ago

As far as I understand the metaplex.nfts().create() function can be also used to create SFT and SPL tokens with metadata. The functions under NFTs could stay there but with a reduced arguments set. Ideally imho it should be like so:

Same should be also done for all other functions related to this. That is much less confusing and makes the api much more intuitive.

lorisleiva commented 1 year ago

Hi there 👋

Thanks for taking the time to provide this feedback.

metaplex.spl().create()

I'm assuming you made a typo here and you meant metaplex.sfts().create() since SPL stands for Solana Program Library.

My issue with the proposed approach is that both NFTs and SFTs, in the context of Metaplex, have an associated Metadata account. If you wish to create tokens without any Metadata account, then you may use the Token module accessible via metaplex.tokens().

That being said, I agree that having NFTs and SFTs under metaplex.nfts() is a bit confusing. An alternative would be to rename this module metaplex.tokenMetadata() to be explicit or metaplex.digitalAssets() to comply with the latest language on the standard.

Does that make sense?

GM-Alex commented 1 year ago

Hi @lorisleiva,

you are totally right I made a typo.

Since, as far as I understand, NFTs and SFTs are a subset of tokens, my idea is to enhance the tokens module in the way that it can create any token with the create command. But since you mentioned that there are tokens without metadata, maybe the module should become a command called createWithMetadata. This would make it also easy to create tokens like for example white list tokens for the candy machine, which also could have metadata.

If the tokens module is then able to create any sort of tokens the nft module could still remain its create method but it uses the new createWithMetadata with preset arguments which shouldn't be able to change, like for example the decimals equals to zero, which makes the creation of NFTs less faulty. For special cases you still have the new createWithMetadata method. Same goes for the SFTs.

What do you think?

lorisleiva commented 1 year ago

Hi there, sorry for the late reply. I think what you're saying makes sense and I'm likely going to change the structure of that module in the future but most people would prefer a high abstraction when creating SFTs and NFTs than using a token module and adding metadata to it.

IMO it mostly comes down to finding a better name for the NFT module as it encapsulates both NFTs and SFTs. Something like metaplex.digitalAssets().createNft() might be a better design.

I'll close this for now since it's not a bug on the SDK but I do appreciate your input on the SDK's API. Thank you!