diff --git a/substrate/srml/contract/src/gas.rs b/substrate/srml/contract/src/gas.rs index 9d1978f7a5..af94ae05c1 100644 --- a/substrate/srml/contract/src/gas.rs +++ b/substrate/srml/contract/src/gas.rs @@ -150,9 +150,12 @@ pub fn buy_gas( let cost = >::as_(gas_limit.clone()) .checked_mul(&gas_price) .ok_or("overflow multiplying gas limit by price")?; - if b < cost + >::existential_deposit() { + + let new_balance = b.checked_sub(&cost); + if new_balance < Some(>::existential_deposit()) { return Err("not enough funds for transaction fee"); } + >::set_free_balance(transactor, b - cost); >::decrease_total_stake_by(cost); Ok(GasMeter {