/// Burn tokens
///
/// Remove `amount` tokens from the system irreversibly, from signer account
///
/// @param amount the amount of money to burn
Burn tokens
Remove `amount` tokens from the system irreversibly, from signer account
Burn tokens Remove ` amount ` tokens from the system irreversibly from signer account
fn try_burn<S: Storage, A: Api, Q: Querier>(
    deps: &mut Extern<S, A, Q>,
    env: Env,
    amount: Uint128,
    memo: Option<String>,
) -> StdResult<HandleResponse> {
    let config = ReadonlyConfig::from_storage(&deps.storage);
    let constants = config.constants()?;
    if !constants.burn_is_enabled {
        return Err(StdError::generic_err(
            "Burn functionality is not enabled for this token.",
        ));
    }
    let sender_address = deps.api.canonical_address(&env.message.sender)?;
    let raw_amount = amount.u128();
    let mut balances = Balances::from_storage(&mut deps.storage);
    let mut account_balance = balances.balance(&sender_address);
    if let Some(new_account_balance) = account_balance.checked_sub(raw_amount) {
        account_balance = new_account_balance;
    } else {
        return Err(StdError::generic_err(format!(
            "insufficient funds to burn: balance={}, required={}",
            account_balance, raw_amount
        )));
    }
    balances.set_account_balance(&sender_address, account_balance);
    let mut config = Config::from_storage(&mut deps.storage);
    let mut total_supply = config.total_supply();
    if let Some(new_total_supply) = total_supply.checked_sub(raw_amount) {
        total_supply = new_total_supply;
    } else {
        return Err(StdError::generic_err(
            "You're trying to burn more than is available in the total supply",
        ));
    }
    config.set_total_supply(total_supply);
    store_burn(
        &mut deps.storage,
        &sender_address,
        &sender_address,
        amount,
        constants.symbol,
        memo,
        &env.block,
    )?;
    let res = HandleResponse {
        messages: vec![],
        log: vec![],
        data: Some(to_binary(&HandleAnswer::Burn { status: Success })?),
    };
    Ok(res)
}
fn try_burn < S : Storage , A : Api , Q : Querier > ( deps : & mut Extern < S , A , Q > , env : Env , amount : Uint128 , memo : Option < String > , ) -> StdResult < HandleResponse > { let config = ReadonlyConfig :: from_storage ( & deps . storage ) ; let constants = config . constants ( ) ? ; if ! constants . burn_is_enabled { return Err ( StdError :: generic_err ( " " , ) ) ; } let sender_address = deps . api . canonical_address ( & env . message . sender ) ? ; let raw_amount = amount . u128 ( ) ; let mut balances = Balances :: from_storage ( & mut deps . storage ) ; let mut account_balance = balances . balance ( & sender_address ) ; if let Some ( new_account_balance ) = account_balance . checked_sub ( raw_amount ) { account_balance = new_account_balance ; } else { return Err ( StdError :: generic_err ( format ! ( " " account_balance raw_amount ) ) ) ; } balances . set_account_balance ( & sender_address , account_balance ) ; let mut config = Config :: from_storage ( & mut deps . storage ) ; let mut total_supply = config . total_supply ( ) ; if let Some ( new_total_supply ) = total_supply . checked_sub ( raw_amount ) { total_supply = new_total_supply ; } else { return Err ( StdError :: generic_err ( " " , ) ) ; } config . set_total_supply ( total_supply ) ; store_burn ( & mut deps . storage , & sender_address , & sender_address , amount , constants . symbol , memo , & env . block , ) ? ; let res = HandleResponse { messages : vec ! [ ] , log : vec ! [ ] , data : Some ( to_binary ( & HandleAnswer :: Burn { status : Success } ) ? ) , } ; Ok ( res ) }
Burn tokens
Remove `amount` tokens from the system irreversibly, from signer account
Burn tokens Remove ` amount ` tokens from the system irreversibly from signer account
deps
&mut Extern<S, A, Q>
env
Env
amount
Uint128
the amount of money to burn
the amount of money to burn
memo
Option<String>