3

When minting new Assets on the Stellar blockchain, is there any way to specify the maximum supply? I'd like to achieve the same effect as an ERC20 where the total supply is fixed by the initial contract implementation.

7

This is fairly straightforward on Stellar, only taking a few steps.

The theory we will take from Stellar's own guide to issuing assets

The practice we can take from Mo's 'hacking-stellar' guide which uses his own 'lumen' CLI tool

1) Create an 'Issuing Account'. This is really nothing more than the account which will issue the asset. You DO NOT want this account to be responsible for anything, you do not want it to handle any other payment transactions, don't really use it for anything else. This will make accounting for the asset simpler and much more straightforward in the future.

$ lumen set config:network test

$ lumen account new BankOfCanada

$ lumen friendbot BankOfCanada

# Create an asset alias called CAD issued by BankOfCanada. Lumen uses the alias as the asset code unless you explicitly specify it with the --code flag.

$ lumen asset set CAD BankOfCanada

2) Create a new "Distributor Account" which will be responsible for the distribution of the asset to other accounts. This should not be the same as the Issuing Account.

# Create a distributor account for BoC CAD

$ lumen account new distributor

$ lumen friendbot distributor

# Add a trustline for the distributor and distribute a fixed supply of CAD

$ lumen trust create distributor CAD

$ lumen pay 10000000000 CAD --from BankOfCanada --to distributor

3) Set the Master Key Weight on the Issuing Account to 0 so that the total supply of the asset is equal to the supply held by the Distributior Account.

$ lumen signers masterweight BankOfCanada 0

Voila! You now have two accounts, one of which is pretty much useless except for transparency / accounting / paper trail purposes, and the other of which has the entire supply of your asset.

  • 1
    The link to the doc is broken. Here's the fixed link: github.com/0xfe/hacking-stellar/blob/master/… – 0xfe Mar 27 '18 at 19:35
  • To be clear, is the change to the master weight on the issuing account irreversible? – Symmetric Mar 27 '18 at 19:58
  • 2
    @Symmetric it's irreversible if there are no other signers on the account with sufficient aggregate weight. – 0xfe Mar 27 '18 at 20:50
  • @0xfe Thanks! I fixed them. – dangerdex Apr 4 '18 at 17:28
2

There is no direct way to set a maximum number of assets. Instead, the intended max number of assets can be created upon initialization, and then the account can be locked up (thus preventing any more assets from being created). Locking up the account is described here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.