0

I want to design a system where token supply can grow infinitely. Is it possible not to fix total supply at the token creation moment?

3
  • How to prevent stackoverflow?
    – Jimmy Guo
    Commented Jun 19, 2019 at 3:22
  • So I should create UINT64_MAX supply at the beginning. Commented Jun 19, 2019 at 13:56
  • This is an old post, but I leave a comment for giving information. The maximum amount of asset is not UINT64_MAX, but eosio::asset::max_amount (2^62 - 1) to avoid overflow.
    – conr2d
    Commented Apr 21, 2020 at 5:32

2 Answers 2

0

No, max supply is set when the token is created and cannot be later changed.

0

Using source code, you should have an update action that will modify maximum_supply and issue a token by symbol.

Example: https://bloks.io/account/vnpittokennn?loadContract=true&tab=Actions&account=vnpittokennn&scope=vnpittokennn&limit=100&action=update

void token::update(name issuer,
                   asset maximum_supply)
{
  require_auth(_self);

  auto sym = maximum_supply.symbol;
  check(sym.is_valid(), "invalid symbol name");
  check(maximum_supply.is_valid(), "invalid supply");
  check(maximum_supply.amount > 0, "max-supply must be positive");

  stats statstable(_self, sym.code().raw());
  auto existing = statstable.find(sym.code().raw());
  check(existing != statstable.end(), "token with symbol does not exist, create token before update");
  const auto &st = *existing;

  check(st.supply.amount <= maximum_supply.amount, "max-supply cannot be less than available supply");
  check(maximum_supply.symbol == st.supply.symbol, "symbol precision mismatch");

  statstable.modify(st, same_payer, [&](auto &s) {
    s.max_supply = maximum_supply;
    s.issuer = issuer;
  });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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