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?
2 Answers
Using source code, you should have an update action that will modify maximum_supply
and issue a token by symbol.
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;
});
}
eosio::asset::max_amount
(2^62 - 1) to avoid overflow.