substrate icon indicating copy to clipboard operation
substrate copied to clipboard

Add max supply to Assets pallet.

Open Szegoo opened this issue 3 years ago • 5 comments

Having a max supply could be useful when creating an asset. It should be something optional. I thought of something like this:

pub fn create(
	origin: OriginFor<T>,
	#[pallet::compact] id: T::AssetId,
	admin: AccountIdLookupOf<T>,
	min_balance: T::Balance,
        max_supply: Option<T::Balance>,
) -> DispatchResult {

The same would go for the force_create.

Szegoo avatar Oct 16 '22 05:10 Szegoo

If this is confirmed I will open a PR for this.

Szegoo avatar Oct 16 '22 05:10 Szegoo

How is max supply different from the concept of total supply?

KiChjang avatar Oct 16 '22 07:10 KiChjang

How is max supply different from the concept of total supply?

Total supply is something that changes when we call the mint function. Max supply is a constant that is set during the creation of the asset(it is specified by the caller). Max supply is always equal to or greater than the total supply. This could limit the amount someone could mint.

The uniques pallet has this implemented, but it would be useful to have this for fungible assets. @KiChjang

Szegoo avatar Oct 16 '22 07:10 Szegoo

In practice, if max supply needs to be respected, we'd just disable the mint functionality, and total supply would just be equivalent to max supply. I don't see the reason to add another storage item just for this.

KiChjang avatar Oct 16 '22 07:10 KiChjang

That could be an approach to this, but I believe that in some situations we don't want all of the max supply to be created. By setting a max supply we would limit how much can be minted, but the total supply may never actually reach max supply.

Szegoo avatar Oct 16 '22 07:10 Szegoo

It is very crucially important for you to understand that storing data on blockchain isn't free. If you can't articulate what "some situations" are concretely, then we will not add such a field to bloat the size of the DB unnecessarily. I suggest that you actually go and investigate around parachains to see whether there's such a need, under what circumstances do they need it, and how this new field can alleviate their issue (or enable more functionality).

KiChjang avatar Nov 05 '22 16:11 KiChjang

@KiChjang In the previous comment I was just trying to note that there might be a situation where we might have a max supply without ever reaching it(e.g. creating an asset and specifying a max supply so that other asset holders can be assured that the asset creators won't mint more than what they have specified when creating the asset). I am very well aware that storing information on blockchain isn't cheap. In this issue I was just giving off an idea to see whether it would be worth implementing to the assets pallet. If you believe that there wouldn't be any scenario where this would be useful I will close this issue.

Szegoo avatar Nov 05 '22 16:11 Szegoo

Sorry, but you are presenting this idea to us. You are supposed to elaborate on your use case, not the other way around.

I have already told you what the best path for you to proceed. We are simply not going to implement something that does not add value until it is demonstrated.

KiChjang avatar Nov 05 '22 17:11 KiChjang