3

I want to burn the tokens i created for some reasons, I found the method "retire" in eosio.token. But, this method only change the supply of the token, the maximum supply is still the same as it is originally.

 {   "rows": [{
       "supply": "9000000000.0000 SYS",
       "max_supply": "**10000000000.0000** SYS",
       "issuer": "eosio"
     }   ],   "more": false 
 }

So, Is there any other method for that ?

2
  • If you want to change the max_supply you can use burntoken action available in eosio.token.cpp. You can also play around this action according to your usecase, I hope this may help.. Commented Jul 15, 2019 at 5:21
  • The max supply is there for limiting the token created, e.g. guaranteeing users of the token that no more than X will ever be created from inflation etc. Please reconsider your strategy of mutating max_supply because I believe this is out of standard practice, otherwise could you further explain your strategy and why such a thing would be warranted? Commented Jul 15, 2019 at 6:28

1 Answer 1

4

The default implementation of eosio.token doesn't support burn you describe. Add next code block to your token contract.

void token::burn( const asset& quantity, const string& memo ) {
   auto sym = quantity.symbol;
   check( sym.is_valid(), "invalid symbol name" );
   check( memo.size() <= 256, "memo has more than 256 bytes" );

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

   require_auth( st.issuer );
   check( quantity.is_valid(), "invalid quantity" );
   check( quantity.amount > 0, "must burn positive quantity" );

   check( quantity.symbol == st.supply.symbol, "symbol precision mismatch" );

   statstable.modify( st, same_payer, [&]( auto& s ) {
      s.supply -= quantity;
      s.max_supply -= quantity; // this line is added compared to `token::retire`
   });

   sub_balance( st.issuer, quantity );
}
3
  • conr2d's solution does not actually burn tokens I'm afraid. It simply reduces the supply/max_supply numbers and won't help making already circulating tokens disappear. Commented Feb 7, 2020 at 2:49
  • @user3883778 This burn action is designed to be executed by token issuer. It reduces supply/max_supply and also reduces token issuer's balance. (You can find sub_balance(st.issuer, quantity); at the last part of code.
    – conr2d
    Commented Feb 7, 2020 at 17:02
  • If you want to make any token owner "burn" token, add name owner as the first parameter of action, check authorization of owner and sub_balance from owner, not issuer.
    – conr2d
    Commented Feb 7, 2020 at 17:03

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.