# Cycle Cost For Installing Wasm

**URL:** <https://forum.dfinity.org/t/cycle-cost-for-installing-wasm/37655>\
**Category:** Developers\
**Created:** [November 22, 2024, 6:18am UTC](https://forum.dfinity.org/t/cycle-cost-for-installing-wasm/37655 "2024-11-22T06:18:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gravity\_vi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gravity_vi/32/35810_2.png) [@gravity\_vi](https://forum.dfinity.org/u/gravity_vi)\
**Post date:** [November 22, 2024, 6:18am UTC](https://forum.dfinity.org/t/cycle-cost-for-installing-wasm/37655/1 "2024-11-22T06:18:32Z")

</div>

I have been calculating the amount of cycles required to upgrade the canister using this formulae and if the canister has enough cycles I move to upgrading the canister

```rs

pub const BASE_COST_FOR_EXECUTION: u128 = 5_000_000; // 5M cycles
pub const RESERVED_NUMBER_OF_INSTRUCTIONS_FOR_INSTALL_CODE: u128 = 200_000_000_000; //200B instructions

pub fn calculate_required_cycles_for_upgrading(
    idle_cycles_burned_per_day: u128,
    freezing_threshold_in_days: Option<u128>,
) -> u128 {
    let freezing_threshold_cycles = get_cycles_reserved_in_freezing_threshold(
        idle_cycles_burned_per_day,
        freezing_threshold_in_days,
    ) //30*idle_cyles_burned_per_day;
    let cycles_required_for_upgrade_execution = BASE_COST_FOR_EXECUTION
        + (RESERVED_NUMBER_OF_INSTRUCTIONS_FOR_INSTALL_CODE);
    freezing_threshold_cycles + cycles_required_for_upgrade_execution
}

```

But I have been observing failures in upgrading a canister saying canister does not have enough cycles. what could be the reason? Let me know if did a mistake in calculating

---

<div class="post-metadata">

**Author:** ![dsarlis](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dsarlis/32/689_2.png) [@dsarlis](https://forum.dfinity.org/u/dsarlis)\
**Post date:** [November 22, 2024, 9:43am UTC](https://forum.dfinity.org/t/cycle-cost-for-installing-wasm/37655/2 "2024-11-22T09:43:04Z")

</div>

The max number of instructions that can be used by an `install_code` request has been increased to [300B](https://sourcegraph.com/github.com/dfinity/ic@fd4d35f4a15324c3e010d4029ea4bffbd8a7a846/-/blob/rs/config/src/subnet_config.rs?L63). It seems you are using the older 200B value.

---

<div class="post-metadata">

**Author:** ![gravity\_vi](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/gravity_vi/32/35810_2.png) [@gravity\_vi](https://forum.dfinity.org/u/gravity_vi)\
**Post date:** [November 22, 2024, 2:04pm UTC](https://forum.dfinity.org/t/cycle-cost-for-installing-wasm/37655/3 "2024-11-22T14:04:28Z")

</div>

Oh alright. Thanks @dsarlis
